API16:JDatabase/splitSql
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
Splits a string of queries into an array of individual queries
Description:JDatabase/splitSql
Syntax
splitSql($queries)
| Parameter Name | Default Value | Description |
|---|---|---|
| $queries | The queries to split |
Returns
array queries
Defined in
libraries/joomla/database/database.php
Importing
jimport( 'joomla.database.database' );
Source Body
public function splitSql($queries) { $start = 0; $open = false; $open_char = ''; $end = strlen($queries); $query_split = array(); for ($i = 0; $i < $end; $i++) { $current = substr($queries,$i,1); if (($current == '"' || $current == '\'')) { $n = 2; while(substr($queries,$i - $n + 1, 1) == '\\' && $n < $i) { $n ++; } if ($n%2==0) { if ($open) { if ($current == $open_char) { $open = false; $open_char = ''; } } else { $open = true; $open_char = $current; } } } if (($current == ';' && !$open)|| $i == $end - 1) { $query_split[] = substr($queries, $start, ($i - $start + 1)); $start = $i + 1; } } return $query_split; }
[Edit See Also] SeeAlso:JDatabase/splitSql
Examples
<CodeExamplesForm />
