Commit fbb5a532 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 46e01370
......@@ -5,20 +5,20 @@ or data is being fetched from the table the component is pointing at Doctrine wi
<code type="php">
\$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();
?></code>
......@@ -10,15 +10,15 @@ when using for example page caching, hence not actually needing a database conne
<code type="php">
// 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');
?></code>
......@@ -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');
</code>
......
......@@ -4,16 +4,16 @@ Opening a new database connection in Doctrine is very easy. If you wish to use P
<code type="php">
\$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();
}
?></code>
</code>
......@@ -22,16 +22,16 @@ If your database extension isn't supported by PDO you can use special Doctrine_A
<code type="php">
\$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();
}
?></code>
</code>
......@@ -40,6 +40,5 @@ The next step is opening a new Doctrine_Connection.
<code type="php">
\$conn = Doctrine_Manager::connection(\$dbh);
?></code>
$conn = Doctrine_Manager::connection($dbh);
</code>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment