本文整理汇总了PHP中TYPO3\CMS\Core\Database\DatabaseConnection::INSERTmultipleRows方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::INSERTmultipleRows方法的具体用法?PHP DatabaseConnection::INSERTmultipleRows怎么用?PHP DatabaseConnection::INSERTmultipleRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Database\DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::INSERTmultipleRows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertNewRelations
/**
* Inserts new relations in the mm table if related records have been submitted
*
* @param array $insertArray
*/
public function insertNewRelations($insertArray)
{
if (!count($insertArray)) {
return;
}
$insertQuery = $this->typo3Db->INSERTmultipleRows($this->table, array($this->uidLocalField, $this->uidForeignField), $insertArray);
$this->utilityFuncs->debugMessage('sql_request', array($insertQuery));
$insertResult = $this->typo3Db->sql_query($insertQuery);
if (!$insertResult) {
$this->utilityFuncs->throwException('Error in SQL query for inserting new relations: ' . $this->typo3Db->sql_error());
}
}
示例2: insertMultipleRowsCreateValidQuery
/**
* @test
*
* @return void
*/
public function insertMultipleRowsCreateValidQuery()
{
$this->subject = $this->getAccessibleMock(DatabaseConnection::class, ['fullQuoteStr'], [], '', false);
$this->subject->expects($this->any())->method('fullQuoteStr')->will($this->returnCallback(function ($data) {
return '\'' . (string) $data . '\'';
}));
$fields = [$this->testField, $this->anotherTestField];
$values = [['Foo', 100], ['Bar', 200], ['Baz', 300]];
$queryExpected = "INSERT INTO {$this->testTable} ({$this->testField}, {$this->anotherTestField}) " . "VALUES ('Foo', '100'), ('Bar', '200'), ('Baz', '300')";
$queryGenerated = $this->subject->INSERTmultipleRows($this->testTable, $fields, $values);
$this->assertSame($queryExpected, $queryGenerated);
}
示例3: INSERTmultipleRows
/**
* Creates an INSERT SQL-statement for $table with multiple rows.
*
* @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 bool|array|string $no_quote_fields See fullQuoteArray()
* @return string|array Full SQL query for INSERT (unless $rows does not contain any elements in which case it will be FALSE)
*/
public function INSERTmultipleRows($table, array $fields, array $rows, $no_quote_fields = FALSE)
{
if ((string) $this->handlerCfg[$this->lastHandlerKey]['type'] === 'native') {
return parent::INSERTmultipleRows($table, $fields, $rows, $no_quote_fields);
}
$result = array();
foreach ($rows as $row) {
$fields_values = array();
foreach ($fields as $key => $value) {
$fields_values[$value] = $row[$key];
}
$rowQuery = $this->INSERTquery($table, $fields_values, $no_quote_fields);
if (is_array($rowQuery)) {
$result[] = $rowQuery;
} else {
$result[][0] = $rowQuery;
}
}
return $result;
}