1
0
mirror of synced 2024-12-15 15:46:02 +03:00
doctrine2/manual/docs/Connection management - Lazy-connecting to database.php

22 lines
897 B
PHP
Raw Normal View History

2006-12-14 16:27:10 +03:00
<?php ?>
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). <br \><br \>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.
<br \> <br \>
<?php
renderCode("<?php
// we may use PDO / PEAR like DSN
// here we use PEAR like DSN
\$dbh = new Doctrine_Db('mysql://username:password@localhost/test');
// !! no actual database connection yet !!
// initalize a new Doctrine_Connection
\$conn = Doctrine_Manager::connection(\$dbh);
// !! no actual database connection yet !!
// connects database and performs a query
\$conn->query('FROM User u');
?>");
?>