2007-04-20 00:41:19 +04:00
|
|
|
|
2007-04-14 01:49:11 +04:00
|
|
|
Lazy-connecting to database is handled via Doctrine_Db wrapper. When using Doctrine_Db instead of PDO / Doctrine_Adapter, lazy-connecting
|
|
|
|
to database is being performed (that means Doctrine will only connect to database when needed).
|
|
|
|
|
|
|
|
This feature can be very useful
|
|
|
|
when using for example page caching, hence not actually needing a database connection on every request. Remember connecting to database is an expensive operation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<code type="php">
|
|
|
|
// we may use PDO / PEAR like DSN
|
|
|
|
// here we use PEAR like DSN
|
2007-05-07 19:44:20 +04:00
|
|
|
$dbh = new Doctrine_Db('mysql://username:password@localhost/test');
|
2007-04-14 01:49:11 +04:00
|
|
|
// !! no actual database connection yet !!
|
|
|
|
|
|
|
|
// initalize a new Doctrine_Connection
|
2007-05-07 19:44:20 +04:00
|
|
|
$conn = Doctrine_Manager::connection($dbh);
|
2007-04-14 01:49:11 +04:00
|
|
|
// !! no actual database connection yet !!
|
|
|
|
|
|
|
|
// connects database and performs a query
|
2007-05-07 19:44:20 +04:00
|
|
|
$conn->query('FROM User u');
|
2007-04-14 01:49:11 +04:00
|
|
|
|
|
|
|
?></code>
|
2007-04-13 00:52:30 +04:00
|
|
|
|