當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DatabaseConnection::INSERTquery方法代碼示例

本文整理匯總了PHP中TYPO3\CMS\Core\Database\DatabaseConnection::INSERTquery方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseConnection::INSERTquery方法的具體用法?PHP DatabaseConnection::INSERTquery怎麽用?PHP DatabaseConnection::INSERTquery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TYPO3\CMS\Core\Database\DatabaseConnection的用法示例。


在下文中一共展示了DatabaseConnection::INSERTquery方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: insertQueryCreateValidQueryFromMultipleValues

 /**
  * @test
  *
  * @return void
  */
 public function insertQueryCreateValidQueryFromMultipleValues()
 {
     $this->subject = $this->getAccessibleMock(DatabaseConnection::class, ['fullQuoteStr'], [], '', false);
     $this->subject->expects($this->any())->method('fullQuoteStr')->will($this->returnCallback(function ($data) {
         return '\'' . (string) $data . '\'';
     }));
     $fieldValues = [$this->testField => 'Foo', $this->anotherTestField => 'Bar'];
     $queryExpected = "INSERT INTO {$this->testTable} ({$this->testField},{$this->anotherTestField}) " . "VALUES ('Foo','Bar')";
     $queryGenerated = $this->subject->INSERTquery($this->testTable, $fieldValues);
     $this->assertSame($queryExpected, $queryGenerated);
 }
開發者ID:dachcom-digital,項目名稱:TYPO3.CMS,代碼行數:16,代碼來源:DatabaseConnectionTest.php

示例2: dbInsert

 /**
  * Db add object
  *
  * @param Tx_Commerce_Dao_BasicDaoObject $object Object
  *
  * @return void
  */
 protected function dbInsert(Tx_Commerce_Dao_BasicDaoObject &$object)
 {
     $dbTable = $this->dbTable;
     $dbModel = $this->parser->parseObjectToModel($object);
     // set pid
     $this->parser->setPid($dbModel, $this->createPid);
     // execute query
     $this->database->exec_INSERTquery($dbTable, $dbModel);
     // any errors
     $error = $this->database->sql_error();
     if (!empty($error)) {
         $this->addError(array($error, $this->database->INSERTquery($dbTable, $dbModel), '$dbModel' => $dbModel));
     }
     // set object id
     $object->setId($this->database->sql_insert_id());
 }
開發者ID:AndreasA,項目名稱:commerce,代碼行數:23,代碼來源:BasicDaoMapper.php

示例3: returnLastBuiltInsertQuery

 /**
  * Returns the last built SQL INSERT query with tabs removed.
  *
  * This function tries to retrieve the last built SQL INSERT query from the database object property $this->debug_lastBuiltQuery (works only since T3 3.8.0 with $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = true). If this does not succeed, a fallback method is used (for former versions of class.\TYPO3\CMS\Core\Database\DatabaseConnection.php [TYPO3 3.6.0-3.8.0beta1] or $GLOBALS['TYPO3_DB']->store_lastBuiltQuery _not_ set to true) to retrieve the query string from \TYPO3\CMS\Core\Database\DatabaseConnection::INSERTquery() - as this is an overhead (\TYPO3\CMS\Core\Database\DatabaseConnection::INSERTquery() is called a second time after the call from \TYPO3\CMS\Core\Database\DatabaseConnection::exec_INSERT_query) IMO this should not be a permanent solution.
  *
  * @param   DatabaseConnection    TYPO3 database object (instance of \TYPO3\CMS\Core\Database\DatabaseConnection) used for last executed SQL query
  * @param   string      table name passed to last executed SQL query (see comment of \TYPO3\CMS\Core\Database\DatabaseConnection::exec_INSERTquery())
  * @param   array       array containing field/value-pairs passed to last executed SQL query (see comment of \TYPO3\CMS\Core\Database\DatabaseConnection::exec_INSERTquery())
  * @return  string      last built SQL query with tabs removed
  * @see                 class.\TYPO3\CMS\Core\Database\DatabaseConnection.php, \TYPO3\CMS\Core\Database\DatabaseConnection::exec_INSERTquery()
  * @author  Rainer Kuhn 
  */
 public static function returnLastBuiltInsertQuery(DatabaseConnection $dbObject, $table, $insertFieldsArr)
 {
     // try to get query from debug_lastBuiltQuery (works only for T3 3.8.0 with $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = true)
     $query = $dbObject->debug_lastBuiltQuery;
     // fallback for former versions of class.\TYPO3\CMS\Core\Database\DatabaseConnection.php (TYPO3 3.6.0-3.8.0beta1) or $GLOBALS['TYPO3_DB']->store_lastBuiltQuery _not_ set to true
     if (strlen($query) < 1) {
         $query = $dbObject->INSERTquery($table, $insertFieldsArr);
     }
     // remove tabs and return query string
     return str_replace(chr(9), '', $query);
 }
開發者ID:punktde,項目名稱:pt_extbase,代碼行數:23,代碼來源:Div.php


注:本文中的TYPO3\CMS\Core\Database\DatabaseConnection::INSERTquery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。