本文整理汇总了PHP中Phinx\Db\Table\Column::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::setType方法的具体用法?PHP Column::setType怎么用?PHP Column::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phinx\Db\Table\Column
的用法示例。
在下文中一共展示了Column::setType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getColumns
/**
* {@inheritdoc}
*/
public function getColumns($tableName)
{
$columns = array();
$rows = $this->fetchAll(sprintf('SHOW COLUMNS FROM %s', $tableName));
foreach ($rows as $columnInfo) {
$column = new Column();
$column->setName($columnInfo['Field'])->setType($columnInfo['Type'])->setNull($columnInfo['Null'] != 'NO')->setDefault($columnInfo['Default']);
$phinxType = $this->getPhinxType($columnInfo['Type']);
$column->setType($phinxType['name'])->setLimit($phinxType['limit']);
if ($columnInfo['Extra'] == 'auto_increment') {
$column->setIdentity(true);
}
$columns[] = $column;
}
return $columns;
}
示例2: getColumns
/**
* {@inheritdoc}
*/
public function getColumns($tableName)
{
$columns = array();
$rows = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName)));
foreach ($rows as $columnInfo) {
$column = new Column();
$type = strtolower($columnInfo['type']);
$column->setName($columnInfo['name'])->setNull($columnInfo['notnull'] != '1')->setDefault($columnInfo['dflt_value']);
$phinxType = $this->getPhinxType($type);
$column->setType($phinxType['name'])->setLimit($phinxType['limit']);
if ($columnInfo['pk'] == 1) {
$column->setIdentity(true);
}
$columns[] = $column;
}
return $columns;
}
示例3: changeColumn
/**
* Change a table column type.
*
* @param string $columnName Column Name
* @param string|Column $newColumnType New Column Type
* @param array $options Options
* @return Table
*/
public function changeColumn($columnName, $newColumnType, $options = array())
{
// create a column object if one wasn't supplied
if (!$newColumnType instanceof Column) {
$newColumn = new Column();
$newColumn->setType($newColumnType);
$newColumn->setOptions($options);
} else {
$newColumn = $newColumnType;
}
// if the name was omitted use the existing column name
if (null === $newColumn->getName() || strlen($newColumn->getName()) === 0) {
$newColumn->setName($columnName);
}
$this->getAdapter()->changeColumn($this->getName(), $columnName, $newColumn);
return $this;
}
示例4: setType
/**
* Sets the column dbType.
*
* @param string $type
*
* @return $this
*/
public function setType($type)
{
$this->column->setType($type);
return $this;
}