PDO Transactions Function transactions for database operation using GOModel


Transaction represent a “block” or “unit” of code that consists of multiple queries that are somehow related to one another. and you might want to ensure that all queries have executed successfully BEFORE you commit the changes to the database. Example: The second query should not be executed if the first query fails. allows to drop a table from database by specifying the table name.

You can start and commit transaction easily using GOModel, you need to call beginTransaction and commitTransaction

Function Defination

                                $GOModel->dbTransaction = true;//start transactions
                                $GOModel->commitTransaction();//commit transaction


                                $GOModel = new GOModel(); //create object of the GOModel class
                                $GOModel->connect("localhost", "root", "", "database");//connect to database
                                /* PDO Transaction block */
                                $GOModel->dbTransaction = true;//start transactions
                                $insertData = array("orderNumber"=>909, "customerName"=>"one", "address"=>"140 shakti nagar");
                                $GOModel->insert("orderTable", $insertData);
                                $insertData = array("orderNumber"=>90099, "customerName"=>"two", "address"=>"140 shakti nagar");
                                $GOModel->insert("orderTable", $insertData);
                                $GOModel->commitTransaction();//commit transaction           


Return true if table dropped successfully


Option Details Example
$GOModel->getLastQuery(); Return last query executed DROP TABLE `tablename`
print_r($GOModel->error) Print errors (if any)