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


PHP Insert::getSqlString方法代碼示例

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


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

示例1: testGetSqlString

 /**
  * @covers Zend\Db\Sql\Insert::getSqlString
  * @todo   Implement testGetSqlString().
  */
 public function testGetSqlString()
 {
     $this->insert->into('foo')->values(array('bar' => 'baz', 'boo' => new Expression('NOW()')));
     $this->assertEquals('INSERT INTO "foo" ("bar", "boo") VALUES (\'baz\', NOW())', $this->insert->getSqlString());
 }
開發者ID:Rovak,項目名稱:zf2,代碼行數:9,代碼來源:InsertTest.php

示例2: testValuesMerge

 /**
  * @group ZF2-536
  */
 public function testValuesMerge()
 {
     $this->insert->into('foo')->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null));
     $this->insert->into('foo')->values(array('qux' => 100), Insert::VALUES_MERGE);
     $this->assertEquals('INSERT INTO "foo" ("bar", "boo", "bam", "qux") VALUES (\'baz\', NOW(), NULL, \'100\')', $this->insert->getSqlString(new TrustingSql92Platform()));
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:9,代碼來源:InsertTest.php

示例3: insert

 /**
  * @throws Exception\InvalidArgumentException on tracking unit already having an ID
  * @throws Exception\RuntimeException         on insert fail
  *
  * @inheritdoc
  */
 public function insert(TrackingUnit $trackingUnit)
 {
     if ($trackingUnit->hasId() === true) {
         $msg = 'Cannot insert tracking unit whth an existing ID';
         throw new Exception\InvalidArgumentException($msg);
     }
     $dbAdapter = $this->getDbAdapter();
     $hydrator = $this->getTrackingUnitHydrator();
     $data = $hydrator->extract($trackingUnit);
     $insert = new Insert(Utils::getTrackingTableName());
     $insert->values($data);
     $sql = $insert->getSqlString($dbAdapter->getPlatform());
     $dbAdapter->query($sql, DbAdapter::QUERY_MODE_EXECUTE);
     $lastVal = $dbAdapter->driver->getLastGeneratedValue();
     if ((bool) $lastVal === false) {
         $msg = 'Insert did not succeed';
         throw new Exception\RuntimeException($msg);
     }
     $trackingUnit->setId($lastVal);
     return $trackingUnit;
 }
開發者ID:xpwales,項目名稱:xpwales-db-migration-lib,代碼行數:27,代碼來源:TrackingUnitDataMapper.php

示例4: assertTableGatewayLastSqlInsert

 /**
  * @param string $expectedSql
  */
 protected function assertTableGatewayLastSqlInsert($expectedSql)
 {
     $actualSql = $this->insert->getSqlString($this->mysqlPlatform);
     $this->assertSqlEquals($expectedSql, $actualSql);
 }
開發者ID:Sam-Burns,項目名稱:table-data-gateway,代碼行數:8,代碼來源:TableGatewayTestCase.php

示例5: getSqlString

 /**
  * Get SQL string for this statement
  *
  * @param  null|PlatformInterface $adapterPlatform Defaults to Sql92 if none provided
  * @return string
  */
 public function getSqlString(PlatformInterface $adapterPlatform = null)
 {
     return parent::getSqlString($adapterPlatform) . " ON DUPLICATE KEY UPDATE " . implode(",", array_map(array($this, "mapValue"), $this->columns));
 }
開發者ID:remithomas,項目名稱:rt-extends,代碼行數:10,代碼來源:DuplicateInsert.php


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