Actions

API15

Difference between revisions of "JDatabaseMySQLi/queryBatch"

From Joomla! Documentation

< API15:JDatabaseMySQLi
(New page: ===Description=== Execute a batch query <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki...)
 
m (removing red link to edit, no existant pages)
 
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JDatabaseMySQLi/queryBatch|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JDatabaseMySQLi/queryBatch}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 77: Line 77:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JDatabaseMySQLi/queryBatch|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JDatabaseMySQLi/queryBatch}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 92: Line 92:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Latest revision as of 08:01, 12 May 2013

Replacement filing cabinet.png
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

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

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

function queryBatch( $abort_on_error=true, $p_transaction_safe = false)
{
        $this->_errorNum = 0;
        $this->_errorMsg = '';
        if ($p_transaction_safe) {
                $this->_sql = rtrim($this->_sql, "; \t\r\n\0");
                $si = $this->getVersion();
                preg_match_all( "/(\d+)\.(\d+)\.(\d+)/i", $si, $m );
                if ($m[1] >= 4) {
                        $this->_sql = 'START TRANSACTION;' . $this->_sql . '; COMMIT;';
                } else if ($m[2] >= 23 && $m[3] >= 19) {
                        $this->_sql = 'BEGIN WORK;' . $this->_sql . '; COMMIT;';
                } else if ($m[2] >= 23 && $m[3] >= 17) {
                        $this->_sql = 'BEGIN;' . $this->_sql . '; COMMIT;';
                }
        }
        $query_split = $this->splitSql($this->_sql);
        $error = 0;
        foreach ($query_split as $command_line) {
                $command_line = trim( $command_line );
                if ($command_line != '') {
                        $this->_cursor = mysqli_query( $this->_resource, $command_line );
                        if ($this->_debug) {
                                $this->_ticker++;
                                $this->_log[] = $command_line;
                        }
                        if (!$this->_cursor) {
                                $error = 1;
                                $this->_errorNum .= mysqli_errno( $this->_resource ) . ' ';
                                $this->_errorMsg .= mysqli_error( $this->_resource )." SQL=$command_line <br />";
                                if ($abort_on_error) {
                                        return $this->_cursor;
                                }
                        }
                }
        }
        return $error ? false : true;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />