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


PHP Column::setName方法代碼示例

本文整理匯總了PHP中Phinx\Db\Table\Column::setName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Column::setName方法的具體用法?PHP Column::setName怎麽用?PHP Column::setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phinx\Db\Table\Column的用法示例。


在下文中一共展示了Column::setName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getColumns

 /**
  * {@inheritdoc}
  */
 public function getColumns($tableName)
 {
     $columns = array();
     $sql = sprintf("SELECT DISTINCT TABLE_SCHEMA AS [schema], TABLE_NAME as [table_name], COLUMN_NAME AS [name], DATA_TYPE AS [type],\n            IS_NULLABLE AS [null], COLUMN_DEFAULT AS [default],\n            CHARACTER_MAXIMUM_LENGTH AS [char_length],\n            NUMERIC_PRECISION AS [precision],\n            NUMERIC_SCALE AS [scale], ORDINAL_POSITION AS [ordinal_position],\n            COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') as [identity]\n        FROM INFORMATION_SCHEMA.COLUMNS\n        WHERE TABLE_NAME = '%s'\n        ORDER BY ordinal_position", $tableName);
     $rows = $this->fetchAll($sql);
     foreach ($rows as $columnInfo) {
         $column = new Column();
         $column->setName($columnInfo['name'])->setType($this->getPhinxType($columnInfo['type']))->setNull($columnInfo['null'] !== 'NO')->setDefault($this->parseDefault($columnInfo['default']))->setIdentity($columnInfo['identity'] === '1')->setComment($this->getColumnComment($columnInfo['table_name'], $columnInfo['name']));
         if (!empty($columnInfo['char_length'])) {
             $column->setLimit($columnInfo['char_length']);
         }
         $columns[$columnInfo['name']] = $column;
     }
     return $columns;
 }
開發者ID:lhas,項目名稱:pep,代碼行數:18,代碼來源:SqlServerAdapter.php

示例2: getColumns

 /**
  * {@inheritdoc}
  */
 public function getColumns($tableName)
 {
     $columns = array();
     $sql = sprintf("SELECT column_name, data_type, is_identity, is_nullable,\n             column_default, character_maximum_length, numeric_precision, numeric_scale\n             FROM information_schema.columns\n             WHERE table_name ='%s'", $tableName);
     $columnsInfo = $this->fetchAll($sql);
     foreach ($columnsInfo as $columnInfo) {
         $column = new Column();
         $column->setName($columnInfo['column_name'])->setType($this->getPhinxType($columnInfo['data_type']))->setNull($columnInfo['is_nullable'] === 'YES')->setDefault($columnInfo['column_default'])->setIdentity($columnInfo['is_identity'] === 'YES')->setPrecision($columnInfo['numeric_precision'])->setScale($columnInfo['numeric_scale']);
         if (preg_match('/\\bwith time zone$/', $columnInfo['data_type'])) {
             $column->setTimezone(true);
         }
         if (isset($columnInfo['character_maximum_length'])) {
             $column->setLimit($columnInfo['character_maximum_length']);
         }
         $columns[] = $column;
     }
     return $columns;
 }
開發者ID:jaambageek,項目名稱:cakeboot-template,代碼行數:21,代碼來源:PostgresAdapter.php

示例3: getColumns

 /**
  * {@inheritdoc}
  */
 public function getColumns($tableName)
 {
     $columns = array();
     $rows = $this->fetchAll(sprintf('SHOW COLUMNS FROM %s', $this->quoteTableName($tableName)));
     foreach ($rows as $columnInfo) {
         $phinxType = $this->getPhinxType($columnInfo['Type']);
         $column = new Column();
         $column->setName($columnInfo['Field'])->setNull($columnInfo['Null'] !== 'NO')->setDefault($columnInfo['Default'])->setType($phinxType['name'])->setLimit($phinxType['limit']);
         if ($columnInfo['Extra'] === 'auto_increment') {
             $column->setIdentity(true);
         }
         $columns[] = $column;
     }
     return $columns;
 }
開發者ID:parkerj,項目名稱:eduTrac-SIS,代碼行數:18,代碼來源:MysqlAdapter.php

示例4: addColumn

 /**
  * Add a table column.
  *
  * Type can be: string, text, integer, float, decimal, datetime, timestamp,
  * time, date, binary, boolean.
  *
  * Valid options can be: limit, default, null, precision or scale.
  *
  * @param string|Column $columnName Column Name
  * @param string $type Column Type
  * @param array $options Column Options
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @return Table
  */
 public function addColumn($columnName, $type = null, $options = array())
 {
     // we need an adapter set to add a column
     if (null === $this->getAdapter()) {
         throw new \RuntimeException('An adapter must be specified to add a column.');
     }
     // create a new column object if only strings were supplied
     if (!$columnName instanceof Column) {
         $column = new Column();
         $column->setName($columnName);
         $column->setType($type);
         $column->setOptions($options);
         // map options to column methods
     } else {
         $column = $columnName;
     }
     // Delegate to Adapters to check column type
     if (!$this->getAdapter()->isValidColumnType($column)) {
         throw new \InvalidArgumentException(sprintf('An invalid column type "%s" was specified for column "%s".', $column->getType(), $column->getName()));
     }
     $this->columns[] = $column;
     return $this;
 }
開發者ID:stephenorr,項目名稱:phinx,代碼行數:38,代碼來源:Table.php

示例5: 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

示例6: setName

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


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