Trac
Doctrine_Query API
Since Doctrine_Query will receive a full DQL, it should not need to take care of DQL generation and build. The new API should be fluent and small, centering functionality in what's supposed to do:
* Handle DQL => SQL generation via Parser calls * Deal with Caching and Hydration
NOTE: It should support chained calls!
The basic planned API is:
$DQL = "SELECT u.* FROM User u WHERE u.id = ?";
// Doctrine_Query object generation
$q = new Doctrine_Query( $DQL );
// OR
$q = $manager->createQuery( $DQL );
// OR
$q = Doctrine_Query::create( $DQL );
// DQL
$oldDql = $q->setDql( $DQL );
$DQL = $q->getDql();
// Hydration mode
$q = $q->setHydrationMode( Doctrine::HYDRATE_ARRAY );
// Parameters
$params = $q->getParams();
$q = $q->setParam( $newParam );
$q = $q->setParams( $params );
// Releases all used resources (and make it possible to be reusable though setDql())
$q->free();
// Copy
$q2 = $q->copy();
// Execution
$rs = $q->execute( $params, $hydrationMode );
$rs = $q->fetchOne( $params, $hydrationMode );
$rs = $q->fetchArray( $params ); // fetchArray( $params ) { execute( $params, Doctrine::HYDRATE_ARRAY ); }
$rs = $q->fetchRecord( $params ); // fetchRecord( $params ) { execute( $params, Doctrine::HYDRATE_RECORD ); }
$rs = $q->fetch( $params ); // fetch( $params ) { execute( $params, Doctrine::HYDRATE_NONE ); }
// Connection
$conn = $q->getConnection();
$oldConn = $q->setConnection( $conn );
// Hydrator
$hydrator = $q->getHydrator();
// Caching stuff
...
[guilhermeblanco: Please add as much information as you can here, so I can merge the ideas into an efficient API]