API16

Difference between revisions of "JDatabaseMySQL/queryBatch"

From Joomla! Documentation

< API16:JDatabaseMySQL
(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:JDatabaseMySQL/queryBatch|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JDatabaseMySQL/queryBatch}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 79: Line 79:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JDatabaseMySQL/queryBatch|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JDatabaseMySQL/queryBatch}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 94: Line 94:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Revision as of 22:01, 12 May 2013

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Execute a batch query

[<! removed edit link to red link >]

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

Syntax[edit]

queryBatch($abort_on_error=true, $p_transaction_safe=false)
Parameter Name Default Value Description
$abort_on_error true
$p_transaction_safe false

Returns[edit]

mixed A database resource if successful, FALSE if not.

Defined in[edit]

libraries/joomla/database/database/mysql.php

Importing[edit]

jimport( 'joomla.database.database.mysql' );

Source Body[edit]

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 = mysql_query($command_line, $this->_connection);
                        if ($this->_debug) {
                                $this->_ticker++;
                                $this->_log[] = $command_line;
                        }
                        if (!$this->_cursor) {
                                $error = 1;
                                $this->_errorNum .= mysql_errno($this->_connection) . ' ';
                                $this->_errorMsg .= mysql_error($this->_connection)." 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[edit]

<CodeExamplesForm />