本文整理汇总了PHP中Phinx\Db\Table::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::create方法的具体用法?PHP Table::create怎么用?PHP Table::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phinx\Db\Table
的用法示例。
在下文中一共展示了Table::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* {@inheritdoc}
*/
public function create()
{
if ((!isset($this->options['id']) || $this->options['id'] === false) && !empty($this->primaryKey)) {
$this->options['primary_key'] = $this->primaryKey;
$this->filterPrimaryKey();
}
parent::create();
}
示例2: testAddTableWithForeignKey
public function testAddTableWithForeignKey()
{
$this->mock->expects($this->any())->method('isValidColumnType')->with($this->callback(function ($column) {
return in_array($column->getType(), array('string', 'integer'));
}))->will($this->returnValue(true));
$table = new Table('table', array(), $this->adapter);
$table->addColumn('bar', 'string')->addColumn('relation', 'integer')->addForeignKey('relation', 'target_table', array('id'));
$this->mock->expects($this->once())->method('createTable')->with($this->callback(function ($table) {
if ($table->getName() !== 'pre_table_suf') {
throw new \Exception(sprintf('Table::getName was not prefixed/suffixed properly: "%s"', $table->getName()));
}
$fks = $table->getForeignKeys();
if (count($fks) !== 1) {
throw new \Exception(sprintf('Table::getForeignKeys count was incorrect: %d', count($fks)));
}
foreach ($fks as $fk) {
if ($fk->getReferencedTable()->getName() !== 'pre_target_table_suf') {
throw new \Exception(sprintf('ForeignKey::getReferencedTable was not prefixed/suffixed properly: "%s"', $fk->getReferencedTable->getName()));
}
}
return true;
}));
$table->create();
}
示例3: create
/**
* Creates a table from the object instance.
*
* @return mixed
*/
public function create()
{
$this->table->create();
return $this;
}