Transaction in Zend Framework with MySQL Or MSSQL | SQL Server and , Using Transaction , Commit and Rollback in Zend PHPBasically, in our common case we want to get “all or nothing” constraint in our database transaction. Usually, in MYSQL the SQL syntax begining a transaction: BEGIN, COMMIT for committing the updates, ROLLBACK for undoing all the updates in the transaction. In Zend Framework, Zend Db interface has its own class methods for beginning, commiting and rollback transaction. Bassically, as follow.
Transactions in zend framework with mysql or mssql
$db->beginTransaction(); //begin a transaction
$db->query(”…”); // query 2
In general web development, transactions are unnecessary. If for some reason post in your CMS isn’t saved, you’ll write it again. It is a problem, but only annoying one, not a crucial one. But if you own a web shop, and someone create an order, pay for it, and you – owner of that store can’t see it because of database glitch, that would be a problem. Take a look at example above. I only first query in that transaction was executed, total amount of money from account would be decreased by 100, and that money would simply disappear (if we’re looking at your database). Or if only second was executed, account 2 would have 100 extra in its total sum – again virtually from nowhere.
Hope you got the Ans !
still having probs ? let me know by comments !
Know More About :
PHP Freelancing India