From fbb5a53223cc979505390e39f6f2ce2570384c0c Mon Sep 17 00:00:00 2001 From: zYne Date: Mon, 7 May 2007 15:44:20 +0000 Subject: [PATCH] --- ...agement - Connection-component binding.php | 14 ++++---- ...nagement - Lazy-connecting to database.php | 6 ++-- ...tion management - Managing connections.php | 2 +- ... management - Opening a new connection.php | 33 +++++++++---------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/manual/docs/Connection management - Connection-component binding.php b/manual/docs/Connection management - Connection-component binding.php index 31700764f..4043007bb 100644 --- a/manual/docs/Connection management - Connection-component binding.php +++ b/manual/docs/Connection management - Connection-component binding.php @@ -5,20 +5,20 @@ or data is being fetched from the table the component is pointing at Doctrine wi -\$conn = \$manager->openConnection(new PDO('dsn','username','password'), 'connection 1'); +$conn = $manager->openConnection(new PDO('dsn','username','password'), 'connection 1'); -\$conn2 = \$manager->openConnection(new PDO('dsn2','username2','password2'), 'connection 2'); +$conn2 = $manager->openConnection(new PDO('dsn2','username2','password2'), 'connection 2'); -\$manager->bindComponent('User', 'connection 1'); +$manager->bindComponent('User', 'connection 1'); -\$manager->bindComponent('Group', 'connection 2'); +$manager->bindComponent('Group', 'connection 2'); -\$q = new Doctrine_Query(); +$q = new Doctrine_Query(); // Doctrine uses 'connection 1' for fetching here -\$users = \$q->from('User u')->where('u.id IN (1,2,3)')->execute(); +$users = $q->from('User u')->where('u.id IN (1,2,3)')->execute(); // Doctrine uses 'connection 2' for fetching here -\$groups = \$q->from('Group g')->where('g.id IN (1,2,3)')->execute(); +$groups = $q->from('Group g')->where('g.id IN (1,2,3)')->execute(); ?> diff --git a/manual/docs/Connection management - Lazy-connecting to database.php b/manual/docs/Connection management - Lazy-connecting to database.php index 6ef736aaa..c2b076be0 100644 --- a/manual/docs/Connection management - Lazy-connecting to database.php +++ b/manual/docs/Connection management - Lazy-connecting to database.php @@ -10,15 +10,15 @@ when using for example page caching, hence not actually needing a database conne // we may use PDO / PEAR like DSN // here we use PEAR like DSN -\$dbh = new Doctrine_Db('mysql://username:password@localhost/test'); +$dbh = new Doctrine_Db('mysql://username:password@localhost/test'); // !! no actual database connection yet !! // initalize a new Doctrine_Connection -\$conn = Doctrine_Manager::connection(\$dbh); +$conn = Doctrine_Manager::connection($dbh); // !! no actual database connection yet !! // connects database and performs a query -\$conn->query('FROM User u'); +$conn->query('FROM User u'); ?> diff --git a/manual/docs/Connection management - Managing connections.php b/manual/docs/Connection management - Managing connections.php index 7c9e6ebc0..c38db5b4a 100644 --- a/manual/docs/Connection management - Managing connections.php +++ b/manual/docs/Connection management - Managing connections.php @@ -12,7 +12,7 @@ $manager = Doctrine_Manager::getInstance(); // open first connection -\$conn = \$manager->openConnection(new PDO('dsn','username','password'), 'connection 1'); +$conn = $manager->openConnection(new PDO('dsn','username','password'), 'connection 1'); diff --git a/manual/docs/Connection management - Opening a new connection.php b/manual/docs/Connection management - Opening a new connection.php index 28277941a..3ef8827ee 100644 --- a/manual/docs/Connection management - Opening a new connection.php +++ b/manual/docs/Connection management - Opening a new connection.php @@ -4,16 +4,16 @@ Opening a new database connection in Doctrine is very easy. If you wish to use P -\$dsn = 'mysql:dbname=testdb;host=127.0.0.1'; -\$user = 'dbuser'; -\$password = 'dbpass'; +$dsn = 'mysql:dbname=testdb;host=127.0.0.1'; +$user = 'dbuser'; +$password = 'dbpass'; try { - \$dbh = new PDO(\$dsn, \$user, \$password); -} catch (PDOException \$e) { - echo 'Connection failed: ' . \$e->getMessage(); + $dbh = new PDO($dsn, $user, $password); +} catch (PDOException $e) { + echo 'Connection failed: ' . $e->getMessage(); } -?> + @@ -22,16 +22,16 @@ If your database extension isn't supported by PDO you can use special Doctrine_A -\$dsn = 'db2:dbname=testdb;host=127.0.0.1'; -\$user = 'dbuser'; -\$password = 'dbpass'; +$dsn = 'db2:dbname=testdb;host=127.0.0.1'; +$user = 'dbuser'; +$password = 'dbpass'; try { - \$dbh = Doctrine_Adapter::connect(\$dsn, \$user, \$password); -} catch (PDOException \$e) { - echo 'Connection failed: ' . \$e->getMessage(); + $dbh = Doctrine_Adapter::connect($dsn, $user, $password); +} catch (PDOException $e) { + echo 'Connection failed: ' . $e->getMessage(); } -?> + @@ -40,6 +40,5 @@ The next step is opening a new Doctrine_Connection. -\$conn = Doctrine_Manager::connection(\$dbh); -?> - +$conn = Doctrine_Manager::connection($dbh); +