本文整理汇总了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());
}
示例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()));
}
示例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;
}
示例4: assertTableGatewayLastSqlInsert
/**
* @param string $expectedSql
*/
protected function assertTableGatewayLastSqlInsert($expectedSql)
{
$actualSql = $this->insert->getSqlString($this->mysqlPlatform);
$this->assertSqlEquals($expectedSql, $actualSql);
}
示例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));
}