本文整理匯總了PHP中Cake\Database\Schema\Table::addConstraintSql方法的典型用法代碼示例。如果您正苦於以下問題:PHP Table::addConstraintSql方法的具體用法?PHP Table::addConstraintSql怎麽用?PHP Table::addConstraintSql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\Database\Schema\Table
的用法示例。
在下文中一共展示了Table::addConstraintSql方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createConstraints
/**
* {@inheritDoc}
*/
public function createConstraints(ConnectionInterface $db)
{
if (empty($this->_constraints)) {
return true;
}
foreach ($this->_constraints as $name => $data) {
$this->_schema->addConstraint($name, $data);
}
$sql = $this->_schema->addConstraintSql($db);
if (empty($sql)) {
return true;
}
foreach ($sql as $stmt) {
$db->execute($stmt)->closeCursor();
}
return true;
}
示例2: testAddConstraintSql
/**
* Test the addConstraintSql method.
*
* @return void
*/
public function testAddConstraintSql()
{
$driver = $this->_getMockedDriver();
$connection = $this->getMockBuilder('Cake\\Database\\Connection')->disableOriginalConstructor()->getMock();
$connection->expects($this->any())->method('driver')->will($this->returnValue($driver));
$table = new Table('posts');
$result = $table->addConstraintSql($connection);
$this->assertEmpty($result);
}