From 6fffa9e68d2e44bdb13680d32870823b0cf8a671 Mon Sep 17 00:00:00 2001 From: zYne Date: Mon, 21 Aug 2006 22:51:27 +0000 Subject: [PATCH] Manual codes updated Session -> Connection --- Doctrine/Collection.php | 9 ++++++++- ...Eventlisteners - Creating new listener.php | 8 ++++---- ...ents - Eventlisteners - List of events.php | 18 ++++++++--------- ...ts - Eventlisteners - Listening events.php | 2 +- ...- Validators - Validating transactions.php | 4 ++-- ...ents - Collection - Accessing elements.php | 2 +- ...nts - Collection - Fetching strategies.php | 10 +++++----- ...- Collection - Loading related records.php | 2 +- ...mponents - Manager - Managing sessions.php | 20 +++++++++---------- ...ents - Manager - Opening a new session.php | 10 +++++----- ...ents - Query - FROM - selecting tables.php | 12 +++++------ ...mponents - Query - Fetching strategies.php | 12 +++++------ ...nd OFFSET - limiting the query results.php | 4 ++-- ...nents - Query - Lazy property fetching.php | 2 +- ...omponents - Query - Method overloading.php | 4 ++-- ...ery - ORDER BY - sorting query results.php | 10 +++++----- ...ery - WHERE - setting query conditions.php | 10 +++++----- ...omponents - RawSql - Adding components.php | 2 +- ...mponents - RawSql - Method overloading.php | 2 +- .../Basic Components - RawSql - Using SQL.php | 2 +- ...onents - Record - Creating new records.php | 4 ++-- ...Components - Record - Deleting records.php | 2 +- ...- Record - Retrieving existing records.php | 4 ++-- ...Components - Record - Updating records.php | 2 +- ...nents - Session - Flushing the session.php | 4 ++-- ...nts - Session - Getting a table object.php | 6 +++--- ...ents - Session - Getting session state.php | 14 ++++++------- ...ents - Session - Querying the database.php | 4 ++-- ...ic Components - Table - Custom finders.php | 8 ++++---- ...ic Components - Table - Finder methods.php | 2 +- ...ts - Table - Getting table information.php | 2 +- ...Database operations - Limit and offset.php | 2 +- ...abase operations - Nested transactions.php | 10 +++++----- .../Database operations - Query logging.php | 2 +- .../codes/Database operations - Sequences.php | 2 +- .../Database operations - Transactions.php | 2 +- ...Join table associations - Many-to-Many.php | 2 +- ...ance - Internal optimizations - DELETE.php | 2 +- ...orld examples - User management system.php | 2 +- .../Runtime classes - Doctrine_Session.php | 16 +++++++-------- manual/codes/Transactions - Introduction.php | 6 +++--- manual/codes/Transactions - Nesting.php | 20 +++++++++---------- manual/codes/Transactions - Unit of work.php | 10 +++++----- tests/QueryLimitTestCase.php | 1 - tests/run.php | 4 ++-- 45 files changed, 142 insertions(+), 136 deletions(-) diff --git a/Doctrine/Collection.php b/Doctrine/Collection.php index 6accf1def..ecda8b09c 100644 --- a/Doctrine/Collection.php +++ b/Doctrine/Collection.php @@ -67,8 +67,15 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator /** * constructor + * + * @param Doctrine_Table|string $table */ - public function __construct(Doctrine_Table $table) { + public function __construct($table) { + if( ! ($table instanceof Doctrine_Table)) + $table = Doctrine_Manager::getInstance() + ->getCurrentConnection() + ->getTable($table); + $this->table = $table; $name = $table->getAttribute(Doctrine::ATTR_COLL_KEY); diff --git a/manual/codes/Advanced components - Eventlisteners - Creating new listener.php b/manual/codes/Advanced components - Eventlisteners - Creating new listener.php index 4ae75f0d7..b0fe91a85 100644 --- a/manual/codes/Advanced components - Eventlisteners - Creating new listener.php +++ b/manual/codes/Advanced components - Eventlisteners - Creating new listener.php @@ -22,13 +22,13 @@ $manager = Doctrine_Manager::getInstance(); $manager->setAttribute(Doctrine::ATTR_LISTENER,new MyListener()); -// setting session level listener -$session = $manager->openSession($dbh); +// setting connection level listener +$conn = $manager->openConnection($dbh); -$session->setAttribute(Doctrine::ATTR_LISTENER,new MyListener2()); +$conn->setAttribute(Doctrine::ATTR_LISTENER,new MyListener2()); // setting factory level listener -$table = $session->getTable("User"); +$table = $conn->getTable("User"); $table->setAttribute(Doctrine::ATTR_LISTENER,new MyListener()); ?> diff --git a/manual/codes/Advanced components - Eventlisteners - List of events.php b/manual/codes/Advanced components - Eventlisteners - List of events.php index daf382388..930017e73 100644 --- a/manual/codes/Advanced components - Eventlisteners - List of events.php +++ b/manual/codes/Advanced components - Eventlisteners - List of events.php @@ -25,19 +25,19 @@ interface iDoctrine_EventListener { public function onWakeUp(Doctrine_Record $record); - public function onClose(Doctrine_Session $session); - public function onPreClose(Doctrine_Session $session); + public function onClose(Doctrine_Connection $conn); + public function onPreClose(Doctrine_Connection $conn); - public function onOpen(Doctrine_Session $session); + public function onOpen(Doctrine_Connection $conn); - public function onTransactionCommit(Doctrine_Session $session); - public function onPreTransactionCommit(Doctrine_Session $session); + public function onTransactionCommit(Doctrine_Connection $conn); + public function onPreTransactionCommit(Doctrine_Connection $conn); - public function onTransactionRollback(Doctrine_Session $session); - public function onPreTransactionRollback(Doctrine_Session $session); + public function onTransactionRollback(Doctrine_Connection $conn); + public function onPreTransactionRollback(Doctrine_Connection $conn); - public function onTransactionBegin(Doctrine_Session $session); - public function onPreTransactionBegin(Doctrine_Session $session); + public function onTransactionBegin(Doctrine_Connection $conn); + public function onPreTransactionBegin(Doctrine_Connection $conn); public function onCollectionDelete(Doctrine_Collection $collection); public function onPreCollectionDelete(Doctrine_Collection $collection); diff --git a/manual/codes/Advanced components - Eventlisteners - Listening events.php b/manual/codes/Advanced components - Eventlisteners - Listening events.php index f3f09f616..e484a88c3 100644 --- a/manual/codes/Advanced components - Eventlisteners - Listening events.php +++ b/manual/codes/Advanced components - Eventlisteners - Listening events.php @@ -1,5 +1,5 @@ getTable("User"); +$table = $conn->getTable("User"); $table->setEventListener(new MyListener2()); diff --git a/manual/codes/Advanced components - Validators - Validating transactions.php b/manual/codes/Advanced components - Validators - Validating transactions.php index 419f20310..6f4160430 100644 --- a/manual/codes/Advanced components - Validators - Validating transactions.php +++ b/manual/codes/Advanced components - Validators - Validating transactions.php @@ -17,7 +17,7 @@ class Email extends Doctrine_Record { $this->hasColumn("address","string",150,"email|unique"); } } -$session = Doctrine_Manager::getInstance()->openSession(new PDO("dsn","username","password")); +$conn = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password")); $user = new User(); $user->name = "this is an example of too long name"; @@ -36,7 +36,7 @@ $user->Email->address = "drink@drinkmore.info"; $user->save(); // saved -$user = $session->create("User"); +$user = $conn->create("User"); $user->Email->address = "drink@drinkmore.info"; // not unique! $user->save(); // throws a Doctrine_Validator_Exception ?> diff --git a/manual/codes/Basic Components - Collection - Accessing elements.php b/manual/codes/Basic Components - Collection - Accessing elements.php index 47e8519b6..b6d08a5bb 100644 --- a/manual/codes/Basic Components - Collection - Accessing elements.php +++ b/manual/codes/Basic Components - Collection - Accessing elements.php @@ -1,5 +1,5 @@ getTable("User"); +$table = $conn->getTable("User"); $users = $table->findAll(); diff --git a/manual/codes/Basic Components - Collection - Fetching strategies.php b/manual/codes/Basic Components - Collection - Fetching strategies.php index ee5cd03ef..d36911490 100644 --- a/manual/codes/Basic Components - Collection - Fetching strategies.php +++ b/manual/codes/Basic Components - Collection - Fetching strategies.php @@ -1,5 +1,5 @@ getTable("User"); +$table = $conn->getTable("User"); $table->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_IMMEDIATE); @@ -7,7 +7,7 @@ $users = $table->findAll(); // or -$users = $session->query("FROM User-I"); // immediate collection +$users = $conn->query("FROM User-I"); // immediate collection foreach($users as $user) { print $user->name; @@ -20,7 +20,7 @@ $users = $table->findAll(); // or -$users = $session->query("FROM User-L"); // lazy collection +$users = $conn->query("FROM User-L"); // lazy collection foreach($users as $user) { print $user->name; @@ -32,7 +32,7 @@ $users = $table->findAll(); // or -$users = $session->query("FROM User-B"); // batch collection +$users = $conn->query("FROM User-B"); // batch collection foreach($users as $user) { print $user->name; @@ -44,7 +44,7 @@ $users = $table->findAll(); // or -$users = $session->query("FROM User-O"); // offset collection +$users = $conn->query("FROM User-O"); // offset collection foreach($users as $user) { print $user->name; diff --git a/manual/codes/Basic Components - Collection - Loading related records.php b/manual/codes/Basic Components - Collection - Loading related records.php index 64715cecd..4407e7240 100644 --- a/manual/codes/Basic Components - Collection - Loading related records.php +++ b/manual/codes/Basic Components - Collection - Loading related records.php @@ -1,5 +1,5 @@ query("FROM User"); +$users = $conn->query("FROM User"); // now lets load phonenumbers for all users diff --git a/manual/codes/Basic Components - Manager - Managing sessions.php b/manual/codes/Basic Components - Manager - Managing sessions.php index ac67cb878..e5d2a1203 100644 --- a/manual/codes/Basic Components - Manager - Managing sessions.php +++ b/manual/codes/Basic Components - Manager - Managing sessions.php @@ -1,25 +1,25 @@ openSession(new PDO("dsn","username","password"), "session 1"); +$conn = $manager->openConnection(new PDO("dsn","username","password"), "connection 1"); -// open second session +// open second connection -$session2 = $manager->openSession(new PDO("dsn2","username2","password2"), "session 2"); +$conn2 = $manager->openConnection(new PDO("dsn2","username2","password2"), "connection 2"); -$manager->getCurrentSession(); // $session2 +$manager->getCurrentConnection(); // $conn2 -$manager->setCurrentSession("session 1"); +$manager->setCurrentConnection("connection 1"); -$manager->getCurrentSession(); // $session +$manager->getCurrentConnection(); // $conn -// iterating through sessions +// iterating through connections -foreach($manager as $session) { +foreach($manager as $conn) { } ?> diff --git a/manual/codes/Basic Components - Manager - Opening a new session.php b/manual/codes/Basic Components - Manager - Opening a new session.php index 8e774cb8e..b28d9a936 100644 --- a/manual/codes/Basic Components - Manager - Opening a new session.php +++ b/manual/codes/Basic Components - Manager - Opening a new session.php @@ -1,18 +1,18 @@ openSession(); +$conn = $manager->openConnection(); // or if you want to use Doctrine Doctrine_DB and its // performance monitoring capabilities $dsn = "schema://username:password@dsn/dbname"; $dbh = Doctrine_DB::getConnection($dsn); -$session = $manager->openSession(); +$conn = $manager->openConnection(); ?> diff --git a/manual/codes/Basic Components - Query - FROM - selecting tables.php b/manual/codes/Basic Components - Query - FROM - selecting tables.php index 6a8001203..430d8005c 100644 --- a/manual/codes/Basic Components - Query - FROM - selecting tables.php +++ b/manual/codes/Basic Components - Query - FROM - selecting tables.php @@ -2,26 +2,26 @@ // find all users -$coll = $session->query("FROM User"); +$coll = $conn->query("FROM User"); // find all users with only their names (and primary keys) fetched -$coll = $session->query("FROM User(name)"); +$coll = $conn->query("FROM User(name)"); // find all groups -$coll = $session->query("FROM Group"); +$coll = $conn->query("FROM Group"); // find all users and user emails -$coll = $session->query("FROM User.Email"); +$coll = $conn->query("FROM User.Email"); // find all users and user emails with only user name and // age + email address loaded -$coll = $session->query("FROM User(name, age).Email(address)"); +$coll = $conn->query("FROM User(name, age).Email(address)"); // find all users, user email and user phonenumbers -$coll = $session->query("FROM User.Email, User.Phonenumber"); +$coll = $conn->query("FROM User.Email, User.Phonenumber"); ?> diff --git a/manual/codes/Basic Components - Query - Fetching strategies.php b/manual/codes/Basic Components - Query - Fetching strategies.php index efdd801c4..8654ac3b5 100644 --- a/manual/codes/Basic Components - Query - Fetching strategies.php +++ b/manual/codes/Basic Components - Query - Fetching strategies.php @@ -1,25 +1,25 @@ query("FROM User-I"); +$coll = $conn->query("FROM User-I"); // or -$coll = $session->query("FROM User-IMMEDIATE"); +$coll = $conn->query("FROM User-IMMEDIATE"); // select all users and load the data in batches -$coll = $session->query("FROM User-B"); +$coll = $conn->query("FROM User-B"); // or -$coll = $session->query("FROM User-BATCH"); +$coll = $conn->query("FROM User-BATCH"); // select all user and use lazy fetching -$coll = $session->query("FROM User-L"); +$coll = $conn->query("FROM User-L"); // or -$coll = $session->query("FROM User-LAZY"); +$coll = $conn->query("FROM User-LAZY"); ?> diff --git a/manual/codes/Basic Components - Query - LIMIT and OFFSET - limiting the query results.php b/manual/codes/Basic Components - Query - LIMIT and OFFSET - limiting the query results.php index 02edc71b6..0df929b59 100644 --- a/manual/codes/Basic Components - Query - LIMIT and OFFSET - limiting the query results.php +++ b/manual/codes/Basic Components - Query - LIMIT and OFFSET - limiting the query results.php @@ -2,10 +2,10 @@ // find the first ten users and their emails -$coll = $session->query("FROM User, User.Email LIMIT 10"); +$coll = $conn->query("FROM User, User.Email LIMIT 10"); // find the first ten users starting from the user number 5 -$coll = $session->query("FROM User LIMIT 10 OFFSET 5"); +$coll = $conn->query("FROM User LIMIT 10 OFFSET 5"); ?> diff --git a/manual/codes/Basic Components - Query - Lazy property fetching.php b/manual/codes/Basic Components - Query - Lazy property fetching.php index d9eba2558..28660b72e 100644 --- a/manual/codes/Basic Components - Query - Lazy property fetching.php +++ b/manual/codes/Basic Components - Query - Lazy property fetching.php @@ -2,5 +2,5 @@ // retrieve all users with only their properties id and name loaded -$users = $session->query("FROM User(id, name)"); +$users = $conn->query("FROM User(id, name)"); ?> diff --git a/manual/codes/Basic Components - Query - Method overloading.php b/manual/codes/Basic Components - Query - Method overloading.php index 1245b7ca3..d9aae392d 100644 --- a/manual/codes/Basic Components - Query - Method overloading.php +++ b/manual/codes/Basic Components - Query - Method overloading.php @@ -1,7 +1,7 @@ openSession(new PDO("dsn","username","password")); +$conn = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password")); -$query = new Doctrine_Query($session); +$query = new Doctrine_Query($conn); $query->from("User-b") ->where("User.name LIKE 'Jack%'") diff --git a/manual/codes/Basic Components - Query - ORDER BY - sorting query results.php b/manual/codes/Basic Components - Query - ORDER BY - sorting query results.php index e3650e7ce..627c7cecc 100644 --- a/manual/codes/Basic Components - Query - ORDER BY - sorting query results.php +++ b/manual/codes/Basic Components - Query - ORDER BY - sorting query results.php @@ -1,21 +1,21 @@ query("FROM User ORDER BY User.name DESC"); +$coll = $conn->query("FROM User ORDER BY User.name DESC"); // find all users sort by name ascending -$coll = $session->query("FROM User ORDER BY User.name ASC"); +$coll = $conn->query("FROM User ORDER BY User.name ASC"); // or -$coll = $session->query("FROM User ORDER BY User.name"); +$coll = $conn->query("FROM User ORDER BY User.name"); // find all users and their emails, sort by email address -$coll = $session->query("FROM User, User.Email ORDER BY User.Email.address"); +$coll = $conn->query("FROM User, User.Email ORDER BY User.Email.address"); // find all users and their emails, sort by user name and email address -$coll = $session->query("FROM User, User.Email ORDER BY User.name, User.Email.address"); +$coll = $conn->query("FROM User, User.Email ORDER BY User.name, User.Email.address"); ?> diff --git a/manual/codes/Basic Components - Query - WHERE - setting query conditions.php b/manual/codes/Basic Components - Query - WHERE - setting query conditions.php index 0b48cc55e..933cd01f0 100644 --- a/manual/codes/Basic Components - Query - WHERE - setting query conditions.php +++ b/manual/codes/Basic Components - Query - WHERE - setting query conditions.php @@ -4,24 +4,24 @@ // find all groups where the group primary key is bigger than 10 -$coll = $session->query("FROM Group WHERE Group.id > 10"); +$coll = $conn->query("FROM Group WHERE Group.id > 10"); // find all users where users where user name matches a regular expression, // REGEXP keyword must be supported by the underlying database -$coll = $session->query("FROM User WHERE User.name REGEXP '[ad]'"); +$coll = $conn->query("FROM User WHERE User.name REGEXP '[ad]'"); // find all users and their associated emails where SOME of the users phonenumbers // (the association between user and phonenumber tables is Many-To-Many) starts with 123 -$coll = $session->query("FROM User, User.Email WHERE User.Phonenumber.phonenumber LIKE '123%'"); +$coll = $conn->query("FROM User, User.Email WHERE User.Phonenumber.phonenumber LIKE '123%'"); // multiple conditions -$coll = $session->query("FROM User WHERE User.name LIKE '%Jack%' && User.Email.address LIKE '%@drinkmore.info'"); +$coll = $conn->query("FROM User WHERE User.name LIKE '%Jack%' && User.Email.address LIKE '%@drinkmore.info'"); // nesting conditions -$coll = $session->query("FROM User WHERE (User.name LIKE '%Jack%' || User.name LIKE '%John%') && User.Email.address LIKE '%@drinkmore.info'"); +$coll = $conn->query("FROM User WHERE (User.name LIKE '%Jack%' || User.name LIKE '%John%') && User.Email.address LIKE '%@drinkmore.info'"); ?> diff --git a/manual/codes/Basic Components - RawSql - Adding components.php b/manual/codes/Basic Components - RawSql - Adding components.php index a1ce031d6..392a73388 100644 --- a/manual/codes/Basic Components - RawSql - Adding components.php +++ b/manual/codes/Basic Components - RawSql - Adding components.php @@ -1,5 +1,5 @@ parseQuery("SELECT {entity.*}, {phonenumber.*} FROM entity diff --git a/manual/codes/Basic Components - RawSql - Method overloading.php b/manual/codes/Basic Components - RawSql - Method overloading.php index 8b49c705b..e99f6f747 100644 --- a/manual/codes/Basic Components - RawSql - Method overloading.php +++ b/manual/codes/Basic Components - RawSql - Method overloading.php @@ -1,5 +1,5 @@ select('{entity.name}') ->from('entity'); diff --git a/manual/codes/Basic Components - RawSql - Using SQL.php b/manual/codes/Basic Components - RawSql - Using SQL.php index 973ec6744..a409801f4 100644 --- a/manual/codes/Basic Components - RawSql - Using SQL.php +++ b/manual/codes/Basic Components - RawSql - Using SQL.php @@ -1,5 +1,5 @@ parseQuery("SELECT {entity.name} FROM entity"); diff --git a/manual/codes/Basic Components - Record - Creating new records.php b/manual/codes/Basic Components - Record - Creating new records.php index 97bee6142..182505abd 100644 --- a/manual/codes/Basic Components - Record - Creating new records.php +++ b/manual/codes/Basic Components - Record - Creating new records.php @@ -1,9 +1,9 @@ create("User"); +$user = $conn->create("User"); // alternative way: -$table = $session->getTable("User"); +$table = $conn->getTable("User"); $user = $table->create(); diff --git a/manual/codes/Basic Components - Record - Deleting records.php b/manual/codes/Basic Components - Record - Deleting records.php index f486f8be3..d15b0cd14 100644 --- a/manual/codes/Basic Components - Record - Deleting records.php +++ b/manual/codes/Basic Components - Record - Deleting records.php @@ -1,5 +1,5 @@ getTable("User"); +$table = $conn->getTable("User"); $user = $table->find(2); diff --git a/manual/codes/Basic Components - Record - Retrieving existing records.php b/manual/codes/Basic Components - Record - Retrieving existing records.php index 9bdf929ee..5b7623cdb 100644 --- a/manual/codes/Basic Components - Record - Retrieving existing records.php +++ b/manual/codes/Basic Components - Record - Retrieving existing records.php @@ -1,5 +1,5 @@ getTable("User"); +$table = $conn->getTable("User"); // find by primary key @@ -19,5 +19,5 @@ foreach($table->findByDql("name LIKE '%John%'") as $user) { // finding objects with DQL -$users = $session->query("FROM User WHERE User.name LIKE '%John%'"); +$users = $conn->query("FROM User WHERE User.name LIKE '%John%'"); ?> diff --git a/manual/codes/Basic Components - Record - Updating records.php b/manual/codes/Basic Components - Record - Updating records.php index 24026fec3..217639483 100644 --- a/manual/codes/Basic Components - Record - Updating records.php +++ b/manual/codes/Basic Components - Record - Updating records.php @@ -1,5 +1,5 @@ getTable("User"); +$table = $conn->getTable("User"); $user = $table->find(2); diff --git a/manual/codes/Basic Components - Session - Flushing the session.php b/manual/codes/Basic Components - Session - Flushing the session.php index 1f56b7e1f..37480533b 100644 --- a/manual/codes/Basic Components - Session - Flushing the session.php +++ b/manual/codes/Basic Components - Session - Flushing the session.php @@ -2,10 +2,10 @@ $user = new User(); $user->name = "Jack"; -$group = $session->create("Group"); +$group = $conn->create("Group"); $group->name = "Drinking Club"; // saves all the changed objects into database -$session->flush(); +$conn->flush(); ?> diff --git a/manual/codes/Basic Components - Session - Getting a table object.php b/manual/codes/Basic Components - Session - Getting a table object.php index 1f5e21983..a2f3db549 100644 --- a/manual/codes/Basic Components - Session - Getting a table object.php +++ b/manual/codes/Basic Components - Session - Getting a table object.php @@ -1,11 +1,11 @@ openSession(new PDO("dsn","username","password")); +$conn = $manager->openConnection(new PDO("dsn","username","password")); // getting a table object -$table = $session->getTable("User"); +$table = $conn->getTable("User"); ?> diff --git a/manual/codes/Basic Components - Session - Getting session state.php b/manual/codes/Basic Components - Session - Getting session state.php index b1589f815..cb709ad08 100644 --- a/manual/codes/Basic Components - Session - Getting session state.php +++ b/manual/codes/Basic Components - Session - Getting session state.php @@ -1,16 +1,16 @@ getState()) - case Doctrine_Session::STATE_ACTIVE: - // session open and zero open transactions +switch($conn->getState()) + case Doctrine_Connection::STATE_ACTIVE: + // connection open and zero open transactions break; - case Doctrine_Session::STATE_ACTIVE: + case Doctrine_Connection::STATE_ACTIVE: // one open transaction break; - case Doctrine_Session::STATE_BUSY: + case Doctrine_Connection::STATE_BUSY: // multiple open transactions break; - case Doctrine_Session::STATE_CLOSED: - // session closed + case Doctrine_Connection::STATE_CLOSED: + // connection closed break; endswitch; ?> diff --git a/manual/codes/Basic Components - Session - Querying the database.php b/manual/codes/Basic Components - Session - Querying the database.php index cfea02b91..0af62777c 100644 --- a/manual/codes/Basic Components - Session - Querying the database.php +++ b/manual/codes/Basic Components - Session - Querying the database.php @@ -2,9 +2,9 @@ // select all users -$session->query("FROM User"); +$conn->query("FROM User"); // select all users where user email is jackdaniels@drinkmore.info -$session->query("FROM User WHERE User.Email.address = 'jackdaniels@drinkmore.info'"); +$conn->query("FROM User WHERE User.Email.address = 'jackdaniels@drinkmore.info'"); ?> diff --git a/manual/codes/Basic Components - Table - Custom finders.php b/manual/codes/Basic Components - Table - Custom finders.php index 1a040f15a..2301ca495 100644 --- a/manual/codes/Basic Components - Table - Custom finders.php +++ b/manual/codes/Basic Components - Table - Custom finders.php @@ -4,18 +4,18 @@ class UserTable extends Doctrine_Table { * you can add your own finder methods here */ public function findByName($name) { - return $this->getSession()->query("FROM User WHERE name LIKE '%$name%'"); + return $this->getConnection()->query("FROM User WHERE name LIKE '%$name%'"); } } class User extends Doctrine_Record { } -$session = Doctrine_Manager::getInstance() - ->openSession(new PDO("dsn","username","password")); +$conn = Doctrine_Manager::getInstance() + ->openConnection(new PDO("dsn","username","password")); // doctrine will now check if a class called UserTable exists // and if it inherits Doctrine_Table -$table = $session->getTable("User"); +$table = $conn->getTable("User"); print get_class($table); // UserTable diff --git a/manual/codes/Basic Components - Table - Finder methods.php b/manual/codes/Basic Components - Table - Finder methods.php index 380e6b48d..9b462c449 100644 --- a/manual/codes/Basic Components - Table - Finder methods.php +++ b/manual/codes/Basic Components - Table - Finder methods.php @@ -1,5 +1,5 @@ getTable("User"); +$table = $conn->getTable("User"); // find by primary key diff --git a/manual/codes/Basic Components - Table - Getting table information.php b/manual/codes/Basic Components - Table - Getting table information.php index ed077cdda..5a90872b1 100644 --- a/manual/codes/Basic Components - Table - Getting table information.php +++ b/manual/codes/Basic Components - Table - Getting table information.php @@ -1,5 +1,5 @@ getTable('User'); +$table = $conn->getTable('User'); // getting column names diff --git a/manual/codes/Database operations - Limit and offset.php b/manual/codes/Database operations - Limit and offset.php index b770a6f6b..eca98ea2e 100644 --- a/manual/codes/Database operations - Limit and offset.php +++ b/manual/codes/Database operations - Limit and offset.php @@ -1,5 +1,5 @@ openSession(new PDO("dsn","username","password")); +$sess = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password")); // select first ten rows starting from the row 20 diff --git a/manual/codes/Database operations - Nested transactions.php b/manual/codes/Database operations - Nested transactions.php index 22cf0924e..a2c5683ab 100644 --- a/manual/codes/Database operations - Nested transactions.php +++ b/manual/codes/Database operations - Nested transactions.php @@ -1,17 +1,17 @@ beginTransaction(); + $conn->beginTransaction(); $user->save(); - $session->beginTransaction(); + $conn->beginTransaction(); $group->save(); $email->save(); - $session->commit(); + $conn->commit(); - $session->commit(); + $conn->commit(); } catch(Exception $e) { - $session->rollback(); + $conn->rollback(); } ?> diff --git a/manual/codes/Database operations - Query logging.php b/manual/codes/Database operations - Query logging.php index 2694b96c9..84aba9454 100644 --- a/manual/codes/Database operations - Query logging.php +++ b/manual/codes/Database operations - Query logging.php @@ -2,7 +2,7 @@ // works only if you use doctrine database handler -$dbh = $session->getDBH(); +$dbh = $conn->getDBH(); $times = $dbh->getExecTimes(); diff --git a/manual/codes/Database operations - Sequences.php b/manual/codes/Database operations - Sequences.php index b671dad1d..f5f3846a5 100644 --- a/manual/codes/Database operations - Sequences.php +++ b/manual/codes/Database operations - Sequences.php @@ -1,5 +1,5 @@ openSession(new PDO("dsn","username","password")); +$sess = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password")); // gets the next ID from a sequence diff --git a/manual/codes/Database operations - Transactions.php b/manual/codes/Database operations - Transactions.php index 46d515774..08f1838ae 100644 --- a/manual/codes/Database operations - Transactions.php +++ b/manual/codes/Database operations - Transactions.php @@ -1,5 +1,5 @@ openSession(new PDO("dsn","username","password")); +$sess = Doctrine_Manager::getInstance()->openConnection(new PDO("dsn","username","password")); try { $sess->beginTransaction(); diff --git a/manual/codes/Mapping object relations - Join table associations - Many-to-Many.php b/manual/codes/Mapping object relations - Join table associations - Many-to-Many.php index fd8be64a4..9001f7b05 100644 --- a/manual/codes/Mapping object relations - Join table associations - Many-to-Many.php +++ b/manual/codes/Mapping object relations - Join table associations - Many-to-Many.php @@ -39,7 +39,7 @@ $user->save(); $user->Groupuser->delete(); -$groups = new Doctrine_Collection($session->getTable("Group")); +$groups = new Doctrine_Collection($conn->getTable("Group")); $groups[0]->name = "Third Group"; diff --git a/manual/codes/Performance - Internal optimizations - DELETE.php b/manual/codes/Performance - Internal optimizations - DELETE.php index 2276fe51a..f9fd255ea 100644 --- a/manual/codes/Performance - Internal optimizations - DELETE.php +++ b/manual/codes/Performance - Internal optimizations - DELETE.php @@ -5,7 +5,7 @@ */ $users->delete(); /** - * On session drivers other than mysql doctrine would now perform three queries + * On connection drivers other than mysql doctrine would now perform three queries * regardless of how many users, emails and phonenumbers there are * * the queries would look something like: diff --git a/manual/codes/Real world examples - User management system.php b/manual/codes/Real world examples - User management system.php index de04d2763..7708f6e65 100644 --- a/manual/codes/Real world examples - User management system.php +++ b/manual/codes/Real world examples - User management system.php @@ -62,7 +62,7 @@ class EntityListener extends Doctrine_EventListener { $manager = Doctrine_Manager::getInstance(); -$session = $manager->openSession(new PDO("DSN","username","password")); +$conn = $manager->openConnection(new PDO("DSN","username","password")); $user = new User(); diff --git a/manual/codes/Runtime classes - Doctrine_Session.php b/manual/codes/Runtime classes - Doctrine_Session.php index b3c802415..f2885f5dc 100644 --- a/manual/codes/Runtime classes - Doctrine_Session.php +++ b/manual/codes/Runtime classes - Doctrine_Session.php @@ -1,18 +1,18 @@ openSession(Doctrine_DB::getConnection("schema://username:password@hostname/database")); +$sess = $manager->openConnection(Doctrine_DB::getConnection("schema://username:password@hostname/database")); -// get session state: +// get connection state: switch($sess): - case Doctrine_Session::STATE_BUSY: + case Doctrine_Connection::STATE_BUSY: // multiple open transactions break; - case Doctrine_Session::STATE_ACTIVE: + case Doctrine_Connection::STATE_ACTIVE: // one open transaction break; - case Doctrine_Session::STATE_CLOSED: + case Doctrine_Connection::STATE_CLOSED: // closed state break; - case Doctrine_Session::STATE_OPEN: + case Doctrine_Connection::STATE_OPEN: // open state and zero open transactions break; endswitch; @@ -21,10 +21,10 @@ endswitch; $dbh = $sess->getDBH(); -// flushing the session +// flushing the connection $sess->flush(); -// print lots of useful info about session: +// print lots of useful info about connection: print $sess; ?> diff --git a/manual/codes/Transactions - Introduction.php b/manual/codes/Transactions - Introduction.php index 5c02299e0..1d03edd11 100644 --- a/manual/codes/Transactions - Introduction.php +++ b/manual/codes/Transactions - Introduction.php @@ -1,13 +1,13 @@ beginTransaction(); +$conn->beginTransaction(); $user = new User(); $user->name = 'New user'; $user->save(); -$user = $session->getTable('User')->find(5); +$user = $conn->getTable('User')->find(5); $user->name = 'Modified user'; $user->save(); -$session->commit(); // all the queries are executed here +$conn->commit(); // all the queries are executed here ?> diff --git a/manual/codes/Transactions - Nesting.php b/manual/codes/Transactions - Nesting.php index d64ec24c1..405831c5f 100644 --- a/manual/codes/Transactions - Nesting.php +++ b/manual/codes/Transactions - Nesting.php @@ -1,23 +1,23 @@ beginTransaction(); +function saveUserAndGroup(Doctrine_Connection $conn, User $user, Group $group) { + $conn->beginTransaction(); $user->save(); - + $group->save(); - $session->commit(); + $conn->commit(); } try { - $session->beginTransaction(); + $conn->beginTransaction(); - saveUserAndGroup($session,$user,$group); - saveUserAndGroup($session,$user2,$group2); - saveUserAndGroup($session,$user3,$group3); + saveUserAndGroup($conn,$user,$group); + saveUserAndGroup($conn,$user2,$group2); + saveUserAndGroup($conn,$user3,$group3); - $session->commit(); + $conn->commit(); } catch(Doctrine_Exception $e) { - $session->rollback(); + $conn->rollback(); } ?> diff --git a/manual/codes/Transactions - Unit of work.php b/manual/codes/Transactions - Unit of work.php index 3946438bc..dd2acb22d 100644 --- a/manual/codes/Transactions - Unit of work.php +++ b/manual/codes/Transactions - Unit of work.php @@ -1,18 +1,18 @@ beginTransaction(); +$conn->beginTransaction(); $user = new User(); $user->name = 'New user'; $user->save(); -$user = $session->getTable('User')->find(5); +$user = $conn->getTable('User')->find(5); $user->name = 'Modified user'; $user->save(); -$pending = $session->getInserts(); // an array containing one element +$pending = $conn->getInserts(); // an array containing one element -$pending = $session->getUpdates(); // an array containing one element +$pending = $conn->getUpdates(); // an array containing one element -$session->commit(); // all the queries are executed here +$conn->commit(); // all the queries are executed here ?> diff --git a/tests/QueryLimitTestCase.php b/tests/QueryLimitTestCase.php index 27809e370..e79ae0c9e 100644 --- a/tests/QueryLimitTestCase.php +++ b/tests/QueryLimitTestCase.php @@ -210,6 +210,5 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($q->getQuery(), "SELECT photo.id AS photo__id, photo.name AS photo__name FROM photo LEFT JOIN phototag ON photo.id = phototag.photo_id LEFT JOIN tag ON tag.id = phototag.tag_id WHERE photo.id IN (SELECT DISTINCT photo.id FROM photo LEFT JOIN phototag ON photo.id = phototag.photo_id LEFT JOIN tag ON tag.id = phototag.tag_id WHERE tag.id = ? LIMIT 100) AND tag.id = ? ORDER BY photo.id DESC"); } - } ?> diff --git a/tests/run.php b/tests/run.php index c1c4c1ea5..99a324864 100644 --- a/tests/run.php +++ b/tests/run.php @@ -28,7 +28,7 @@ require_once("QueryLimitTestCase.php"); error_reporting(E_ALL); $test = new GroupTest("Doctrine Framework Unit Tests"); -/** + $test->addTestCase(new Doctrine_RecordTestCase()); $test->addTestCase(new Doctrine_SessionTestCase()); @@ -66,7 +66,7 @@ $test->addTestCase(new Doctrine_CollectionTestCase()); $test->addTestCase(new Doctrine_QueryTestCase()); $test->addTestCase(new Doctrine_RawSql_TestCase()); -*/ + $test->addTestCase(new Doctrine_Query_Limit_TestCase()); //$test->addTestCase(new Doctrine_Cache_FileTestCase());