当前位置: 首页>>代码示例>>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;未经允许,请勿转载。