本文整理汇总了PHP中Propel\Generator\Model\Table::getBehavior方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::getBehavior方法的具体用法?PHP Table::getBehavior怎么用?PHP Table::getBehavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Table
的用法示例。
在下文中一共展示了Table::getBehavior方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHasBehaviors
public function testHasBehaviors()
{
$behavior1 = $this->getBehaviorMock('Foo');
$behavior2 = $this->getBehaviorMock('Bar');
$behavior3 = $this->getBehaviorMock('Baz');
$table = new Table();
$table->addBehavior($behavior1);
$table->addBehavior($behavior2);
$table->addBehavior($behavior3);
$this->assertCount(3, $table->getBehaviors());
$this->assertTrue($table->hasBehavior('Foo'));
$this->assertTrue($table->hasBehavior('Bar'));
$this->assertTrue($table->hasBehavior('Baz'));
$this->assertFalse($table->hasBehavior('Bab'));
$this->assertSame($behavior1, $table->getBehavior('Foo'));
$this->assertSame($behavior2, $table->getBehavior('Bar'));
$this->assertSame($behavior3, $table->getBehavior('Baz'));
}
示例2: createTriggerDDL
/**
* Returns the DQL to create a new trigger.
*
* @param Table $table
*
* @return string
*/
protected function createTriggerDDL(Table $table)
{
/** @var CompositeNumberRangeBehavior $behavior */
$behavior = $table->getBehavior(self::BEHAVIOR_NAME);
$foreignTableName = $behavior->getForeignTable();
$triggerName = $this->getTriggerName($table);
$tableName = $table->getName();
$sql = "\nDELIMITER \$;\n\nCREATE TRIGGER {$triggerName}\nBEFORE INSERT ON {$tableName}\nFOR EACH ROW\nBEGIN\n INSERT INTO {$foreignTableName}_sequence (\n table_name, {$foreignTableName}_id, {$foreignTableName}_max_sequence_id\n ) VALUES (\n '{$tableName}', NEW.{$foreignTableName}_id, LAST_INSERT_ID(1)\n ) ON DUPLICATE KEY\n UPDATE {$foreignTableName}_max_sequence_id = LAST_INSERT_ID({$foreignTableName}_max_sequence_id +1);\n\n SET NEW.{$foreignTableName}_{$tableName}_id = LAST_INSERT_ID();\nEND\n\nDELIMITER ;\n";
return $sql;
}