Feature #21753 » 12858_01.diff
t3lib/class.t3lib_db.php (working copy) | ||
---|---|---|
}
|
||
/**
|
||
* Creates and executes an INSERT SQL-statement for $table with multiple rows.
|
||
*
|
||
* @param string Table name
|
||
* @param array Field names
|
||
* @param array Table rows. Each row should be an array with field values mapping to $fields
|
||
* @param string/array See fullQuoteArray()
|
||
* @return pointer MySQL result pointer / DBAL object
|
||
*/
|
||
public function exec_INSERTmultipleRows($table, $fields, $rows, $no_quote_fields = FALSE) {
|
||
$res = mysql_query($this->INSERTmultipleRows($table, $fields, $rows, $no_quote_fields), $this->link);
|
||
if ($this->debugOutput) {
|
||
$this->debug('exec_INSERTmultiple');
|
||
}
|
||
return $res;
|
||
}
|
||
/**
|
||
* Creates and executes an UPDATE SQL-statement for $table where $where-clause (typ. 'uid=...') from the array with field/value pairs $fields_values.
|
||
* Using this function specifically allow us to handle BLOB and CLOB fields depending on DB
|
||
* Usage count/core: 50
|
||
... | ... | |
}
|
||
/**
|
||
* Creates an INSERT SQL-statement for $table with multiple rows.
|
||
*
|
||
* @param string Table name
|
||
* @param array Field names
|
||
* @param array Table rows. Each row should be an array with field values mapping to $fields
|
||
* @param string/array See fullQuoteArray()
|
||
* @return string Full SQL query for INSERT (unless $fields_values does not contain any elements in which case it will be false)
|
||
*/
|
||
public function INSERTmultipleRows($table, $fields, $rows, $no_quote_fields = FALSE) {
|
||
// Table and fieldnames should be "SQL-injection-safe" when supplied to this
|
||
// function (contrary to values in the arrays which may be insecure).
|
||
if (is_array($fields) && is_array($rows) && count($rows)) {
|
||
// Build query:
|
||
$query = 'INSERT INTO ' . $table .
|
||
'(' . implode(',', $fields) . ') VALUES ';
|
||
$rowSQL = array();
|
||
foreach ($rows as $row) {
|
||
// quote and escape values
|
||
$row = $this->fullQuoteArray($row, $table, $no_quote_fields);
|
||
$rowSQL[] = '( ' . implode(',', $row) . ') ';
|
||
}
|
||
$query .= implode(',', $rowSQL);
|
||
// Return query:
|
||
if ($this->debugOutput || $this->store_lastBuiltQuery) {
|
||
$this->debug_lastBuiltQuery = $query;
|
||
}
|
||
return $query;
|
||
}
|
||
}
|
||
/**
|
||
* Creates an UPDATE SQL-statement for $table where $where-clause (typ. 'uid=...') from the array with field/value pairs $fields_values.
|
||
* Usage count/core: 6
|
||
*
|