/** * Creates an INSERT SQL-statement for $table with multiple rows. Drop in replacement for the same function from core database connections, because this does not allow NULL. * * @param string $table Table name * @param array $fields Field names * @param array $rows Table rows. Each row should be an array with field values mapping to $fields * @param boolean $no_quote_fields See fullQuoteArray() * @return string|NULL Full SQL query for INSERT, NULL if $rows is empty */ protected function INSERTmultipleRows($table, array $fields, array $rows, $no_quote_fields = FALSE) { // Build query $query = 'INSERT INTO ' . $table . ' (' . implode(', ', $fields) . ') VALUES '; $rowSQL = array(); foreach ($rows as $row) { // Quote and escape values $row = $this->db->fullQuoteArray($row, $table, $no_quote_fields, TRUE); $rowSQL[] = '(' . implode(', ', $row) . ')'; } $query .= implode(', ', $rowSQL); return $query; }