Re: New PDO-based DBAL/ORM for PEAR2
| From: | Bertrand Mansion | Date: | Wed, 21 Nov 2007 08:41:21 +0000 |
| Subject: | Re: New PDO-based DBAL/ORM for PEAR2 | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-48542@lists.php.net to get a copy of this message | ||
Le 21 nov. 07 à 09:11, Bertrand Mansion a écrit :
Actually I use Session objects which hold each a distinct pdo object. Sessions are created with Phreez::connect($pdo, $id = '__default__'). Then, if I want to switch to another session, I use Phreez::useSession($id = '__default__). Thinking about it, my Session objects might look like your Domains and hold information about objects already loaded(?). For handling relations, I don't use RoR has_many etc, I think it's not good. I use a RelationRegistry that hods information about all the relations between objects in the database. Relations are represented as objects, they are able to automatically create joined queries for select, updates, etc. The RelationRegistry can be queried at any time by any other object. -- Bertrand Mansion Mamasam Work : http://www.mamasam.com Blog : http://golgote.freeflux.netSingleton doesn't create a new database instance. Instead, if you are connecting with the same DSN, username, and password, it will return the same database connection that has already been established with that combination. It's nice so that you don't create multiple database connections with the exact same connection parameters.I use named connections for that and only one method : getConnection($id = '__default__) IMO, no need for a meaningless singleton method. It's appealing at first to use such method names in your code but it just confuse users in the end because they have no idea what a singleton is or what will be returned.