references:joomla.framework:database:jdatabase-querybatchTable of Contents
queryBatch
Executes the current SQL query string as a single transaction. This function can accept a semi-colon (’;’) separated list of SQL query strings and execute them in a single call. If the $transaction_safe parameter is true then all of the individual query strings must complete successfully or else they will all be rolled back. Syntaxmixed queryBatch ( $abort_on_error, $p_transaction_safe )
ExamplesExample $database =& JFactory::getDBO(); $sql = "INSERT INTO #__users (name) VALUES ('bob'); " . "INSERT INTO #__users (name) VALUES ('frank'); " . "INSERT INTO #__users (name) VALUES ('allen'); " . "INSERT INTO #__users (name) VALUES ('joseph'); "; $database->setQuery( $sql ); if (!$result = $database->queryBatch()) { echo $database->stderr(); } if ($result) { echo "Queries executed successfully! "; } echo $database->getAffectedRows( ); might produce: Result Queries executed successfully! 1
Discussion |


