API16:JDatabaseMySQLi/queryBatch
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Execute a batch query
Description:JDatabaseMySQLi/queryBatch
Syntax
queryBatch($abort_on_error=true, $p_transaction_safe=false)
| Parameter Name | Default Value | Description |
|---|---|---|
| $abort_on_error | true | |
| $p_transaction_safe | false |
Returns
mixed A database resource if successful, FALSE if not.
Defined in
libraries/joomla/database/database/mysqli.php
Importing
jimport( 'joomla.database.database.mysqli' );
Source Body
public function queryBatch($abort_on_error=true, $p_transaction_safe = false) { $sql = $this->replacePrefix((string) $this->_sql); $this->_errorNum = 0; $this->_errorMsg = ''; if ($p_transaction_safe) { $sql = rtrim($sql, "; \t\r\n\0"); $si = $this->getVersion(); preg_match_all("/(\d+)\.(\d+)\.(\d+)/i", $si, $m); if ($m[1] >= 4) { $sql = 'START TRANSACTION;' . $sql . '; COMMIT;'; } else if ($m[2] >= 23 && $m[3] >= 19) { $sql = 'BEGIN WORK;' . $sql . '; COMMIT;'; } else if ($m[2] >= 23 && $m[3] >= 17) { $sql = 'BEGIN;' . $sql . '; COMMIT;'; } } $query_split = $this->splitSql($sql); $error = 0; foreach ($query_split as $command_line) { $command_line = trim($command_line); if ($command_line != '') { $this->_cursor = mysqli_query($this->_connection, $command_line); if ($this->_debug) { $this->_ticker++; $this->_log[] = $command_line; } if (!$this->_cursor) { $error = 1; $this->_errorNum .= mysqli_errno($this->_connection) . ' '; $this->_errorMsg .= mysqli_error($this->_connection)." SQL=$command_line <br />"; if ($abort_on_error) { return $this->_cursor; } } } } return $error ? false : true; }
[Edit See Also] SeeAlso:JDatabaseMySQLi/queryBatch
Examples
<CodeExamplesForm />
