當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Column::setType方法代碼示例

本文整理匯總了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;
 }
開發者ID:alprs,項目名稱:phinx,代碼行數:19,代碼來源:MysqlAdapter.php

示例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;
 }
開發者ID:elliotwms,項目名稱:phinx,代碼行數:20,代碼來源:SQLiteAdapter.php

示例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;
 }
開發者ID:stephenorr,項目名稱:phinx,代碼行數:25,代碼來源:Table.php

示例4: setType

 /**
  * Sets the column dbType.
  *
  * @param string $type
  *
  * @return $this
  */
 public function setType($type)
 {
     $this->column->setType($type);
     return $this;
 }
開發者ID:nilopc-interesting-libs,項目名稱:sql-schema-builder,代碼行數:12,代碼來源:Column.php


注:本文中的Phinx\Db\Table\Column::setType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。