Re: [PDO] Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver

[email protected] (Lester Caine) Tue, 25 May 2010 11:21:39 +0100
Newsgroups php.pdo
Message-ID <[email protected]>
The other examples need to be included in the wiki somewhere for discussion ...

Denis Gasparin wrote:
> Another way could be to maintain a generic PDO driver with a standard dsn (for example "username:password@host/dbname" or the PDO standard "db:host=..,dbname=...") and then to inject a "strategy" to use for database connection and other specific DBMS functions.
>
> For example:
>
> $fbDb = new PDOFirebirdDatabase();
>
> $dbhpool = new PDO('user:pwd@pool/dbname',$fbDb);
>
> $dbhpool->db->attachChild(new PDOFirebirdConnection(..));
> $dbhpool->db->attachChild(new PDOFirebirdConnection(..));
> $dbhpool->db->beginTransaction());

The only problem I see with this is that one would normally be carrying out 
activity on one or other connections to check information, before carrying out 
an update that requires a 2 phase commit. And the operations are still carried 
out on one or other connection, so the $dbhpool->db-> still needs to know WHICH 
connection to carry the query out on.

 From one of the other examples ...
> Or the same as transaction object...
>
> $tobj = new PDOCrossTransaction();
> $tobj->attach($dbh1);
> $tobj->attach($dbh2);
> $tobj->beginTransaction($options);
>
> + Can change the function declaration for transaction options
Provided that $dbh1 and $dbh2 can be used within the transaction to identify the 
connection required. Firebird/Interbase normally has both the connection AND 
transaction passed to any activity so that 'query' for instance knows which 
transaction is active. So $dbh1->beginTransaction() would need to know that 
there is a PDOCrossTransaction active already.

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php