当前位置: 首页>>代码示例>>PHP>>正文


PHP DatabaseConnection::INSERTmultipleRows方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:astehlik,项目名称:typo3-extension-formhandler_subscription,代码行数:17,代码来源:UpdateMmData.php

示例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);
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:17,代码来源:DatabaseConnectionTest.php

示例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;
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:29,代码来源:DatabaseConnection.php


注:本文中的TYPO3\CMS\Core\Database\DatabaseConnection::INSERTmultipleRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。