I could not find any functions in PHP that provide transaction support for mySQL. So, are there any such functions available?? Moreover, are there any classes available that provide OO interface to mysql interaction via PHP???
To run a query you use the mysql_query() function. There are probably many classes to handle queries, I personally have used adodb http://adodb.sourceforge.net/ e39m5
you can use the PEAR DB package: this includes interfaces for most common database. I can't post the url yet (don't have enough posts :s): but just remove the whitespace from the one below: pear. php.net/package/DB
After some frantic searching, I found about the following PHP libraries & PEAR packages: mysqli, PDO, ADODB, PEAR DB & PEAR MDB2. Well, I am not necessarily looking at DB portability. I am looking at a library that provides some efficiency, makes more programming sense & structure than that provided by raw PHP mysql functions & is easy to maintain. Going by that criteria, I have zeroed on to ADODB & PDO. So, can anyone tell me which of these (from all the 5 listed above) will be more suitable for my criteria? Also, does any of them has specific mysql Engine requirements???
Unless you are using a DAL (see below), transactions are managed through SQL queries. There is an OO interface in PHP5, see mysqli (note the "i"), or you can use a database abstraction layer (DAL) such as adoDB and PDO. I would stay away from Pear:B though.
Why, did you have any problems with it? I've been using it for a couple of years now, it never let me down. I think it's a great alternative if you don't have the PDO dal installed
It seemed that it tried to be a god class, was not structured properly into classes and derivations for connections, queries, query results and transactions etc. Also, I remember just include()'ing the file was enough of a performance hit.
Going by the advices above & my own searching, I am narrowing down to just PDO. I again stress that I am not lookking for DB portability. I am looking for some efficiency, & more importantly, a well-structured class hierarchy so that it can be used & maintained easily in PHP code... Any suggestions???
You can directly pass transaction queries like 'BEGIN','COMMINT','ROLLBACK' via mysql_query() function.