当前位置: 首页>>代码示例>>PHP>>正文


PHP CI_DB_forge::_alter_table方法代码示例

本文整理汇总了PHP中CI_DB_forge::_alter_table方法的典型用法代码示例。如果您正苦于以下问题:PHP CI_DB_forge::_alter_table方法的具体用法?PHP CI_DB_forge::_alter_table怎么用?PHP CI_DB_forge::_alter_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CI_DB_forge的用法示例。


在下文中一共展示了CI_DB_forge::_alter_table方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _alter_table

 /**
  * ALTER TABLE
  *
  * @param    string $alter_type ALTER type
  * @param    string $table Table name
  * @param    mixed $field Column definition
  * @return    string|string[]
  */
 protected function _alter_table($alter_type, $table, $field)
 {
     if ($alter_type === 'DROP') {
         return parent::_alter_table($alter_type, $table, $field);
     } elseif ($alter_type === 'CHANGE') {
         $alter_type = 'MODIFY';
     }
     $sql = 'ALTER TABLE ' . $this->db->escape_identifiers($table);
     $sqls = array();
     for ($i = 0, $c = count($field); $i < $c; $i++) {
         if ($field[$i]['_literal'] !== FALSE) {
             $field[$i] = "\n\t" . $field[$i]['_literal'];
         } else {
             $field[$i]['_literal'] = "\n\t" . $this->_process_column($field[$i]);
             if ($alter_type === 'MODIFY' && !empty($field[$i]['new_name'])) {
                 $sqls[] = $sql . ' RENAME COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ' ' . $this->db->escape_identifiers($field[$i]['new_name']);
             }
         }
     }
     $sql .= ' ' . $alter_type . ' ';
     $sql .= count($field) === 1 ? $field[0] : '(' . implode(',', $field) . ')';
     // RENAME COLUMN must be executed after MODIFY
     array_unshift($sqls, $sql);
     return $sql;
 }
开发者ID:at15,项目名称:codeignitordb,代码行数:33,代码来源:oci8_forge.php

示例2: _alter_table

 /**
  * ALTER TABLE
  *
  * @param    string $alter_type ALTER type
  * @param    string $table Table name
  * @param    mixed $field Column definition
  * @return    string|string[]
  */
 protected function _alter_table($alter_type, $table, $field)
 {
     if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) {
         return parent::_alter_table($alter_type, $table, $field);
     }
     $sql = 'ALTER TABLE ' . $this->db->escape_identifiers($table);
     $sqls = array();
     for ($i = 0, $c = count($field); $i < $c; $i++) {
         if ($field[$i]['_literal'] !== FALSE) {
             return FALSE;
         }
         if (version_compare($this->db->version(), '8', '>=') && isset($field[$i]['type'])) {
             $sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ' TYPE ' . $field[$i]['type'] . $field[$i]['length'];
         }
         if (!empty($field[$i]['default'])) {
             $sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ' SET DEFAULT ' . $field[$i]['default'];
         }
         if (isset($field[$i]['null'])) {
             $sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ($field[$i]['null'] === TRUE ? ' DROP NOT NULL' : ' SET NOT NULL');
         }
         if (!empty($field[$i]['new_name'])) {
             $sqls[] = $sql . ' RENAME COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ' TO ' . $this->db->escape_identifiers($field[$i]['new_name']);
         }
     }
     return $sqls;
 }
开发者ID:at15,项目名称:codeignitordb,代码行数:34,代码来源:postgre_forge.php

示例3: _alter_table

 /**
  * ALTER TABLE
  *
  * @param	string	$alter_type	ALTER type
  * @param	string	$table		Table name
  * @param	mixed	$field		Column definition
  * @return	string|string[]
  */
 protected function _alter_table($alter_type, $table, $field)
 {
     if (in_array($alter_type, array('ADD', 'DROP'), TRUE)) {
         return parent::_alter_table($alter_type, $table, $field);
     }
     $sql = 'ALTER TABLE ' . $this->db->escape_identifiers($table) . ' ALTER COLUMN ';
     $sqls = array();
     for ($i = 0, $c = count($field); $i < $c; $i++) {
         $sqls[] = $sql . $this->_process_column($field[$i]);
     }
     return $sqls;
 }
开发者ID:NaszvadiG,项目名称:codeigniter-database-standalone,代码行数:20,代码来源:mssql_forge.php

示例4: _alter_table

 /**
  * ALTER TABLE
  *
  * @param	string	$alter_type	ALTER type
  * @param	string	$table		Table name
  * @param	mixed	$field		Column definition
  * @return	string|string[]
  */
 protected function _alter_table($alter_type, $table, $field)
 {
     if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) {
         return parent::_alter_table($alter_type, $table, $field);
     }
     $sql = 'ALTER TABLE ' . $this->db->escape_identifiers($table);
     $sqls = array();
     for ($i = 0, $c = count($field); $i < $c; $i++) {
         if ($field[$i]['_literal'] !== FALSE) {
             $sqls[] = $sql . ' CHANGE ' . $field[$i]['_literal'];
         } else {
             $alter_type = empty($field[$i]['new_name']) ? ' MODIFY ' : ' CHANGE ';
             $sqls[] = $sql . $alter_type . $this->_process_column($field[$i]);
         }
     }
     return $sqls;
 }
开发者ID:marketcoinfork,项目名称:BitWasp-Fork,代码行数:25,代码来源:cubrid_forge.php

示例5: _alter_table

 /**
  * ALTER TABLE
  *
  * @param	string	$alter_type	ALTER type
  * @param	string	$table		Table name
  * @param	mixed	$field		Column definition
  * @return	string|string[]
  */
 protected function _alter_table($alter_type, $table, $field)
 {
     if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) {
         return parent::_alter_table($alter_type, $table, $field);
     }
     $sql = 'ALTER TABLE ' . $this->db->escape_identifiers($table);
     $sqls = array();
     for ($i = 0, $c = count($field), $sql .= $alter_type . ' '; $i < $c; $i++) {
         if ($field[$i]['_literal'] !== FALSE) {
             return FALSE;
         }
         if (isset($field[$i]['type'])) {
             $sqls[] = $sql . ' TYPE ' . $field[$i]['type'] . $field[$i]['length'];
         }
         if (!empty($field[$i]['default'])) {
             $sqls[] = $sql . ' ALTER ' . $this->db->escape_identifiers($field[$i]['name']) . ' SET ' . $field[$i]['default'];
         }
         if (isset($field[$i]['null'])) {
             $sqls[] = 'UPDATE "RDB$RELATION_FIELDS" SET "RDB$NULL_FLAG" = ' . ($field[$i]['null'] === TRUE ? 'NULL' : '1') . ' WHERE "RDB$FIELD_NAME" = ' . $this->db->escape($field[$i]['name']) . ' AND "RDB$RELATION_NAME" = ' . $this->db->escape($table);
         }
         if (!empty($field[$i]['new_name'])) {
             $sqls[] = $sql . ' ALTER ' . $this->db->escape_identifiers($field[$i]['name']) . ' TO ' . $this->db->escape_identifiers($field[$i]['new_name']);
         }
     }
     return $sqls;
 }
开发者ID:rud0lph,项目名称:ci-guestbook,代码行数:34,代码来源:ibase_forge.php

示例6: _alter_table

 /**
  * ALTER TABLE
  *
  * @todo	implement drop_column(), modify_column()
  * @param	string	$alter_type	ALTER type
  * @param	string	$table		Table name
  * @param	mixed	$field		Column definition
  * @return	string|string[]
  */
 protected function _alter_table($alter_type, $table, $field)
 {
     if ($alter_type === 'DROP' or $alter_type === 'CHANGE') {
         // drop_column():
         //	BEGIN TRANSACTION;
         //	CREATE TEMPORARY TABLE t1_backup(a,b);
         //	INSERT INTO t1_backup SELECT a,b FROM t1;
         //	DROP TABLE t1;
         //	CREATE TABLE t1(a,b);
         //	INSERT INTO t1 SELECT a,b FROM t1_backup;
         //	DROP TABLE t1_backup;
         //	COMMIT;
         return FALSE;
     }
     return parent::_alter_table($alter_type, $table, $field);
 }
开发者ID:alyayazilim,项目名称:E-Ticaret-2015,代码行数:25,代码来源:sqlite3_forge.php

示例7: _alter_table

 /**
  * ALTER TABLE
  *
  * @param	string	$alter_type	ALTER type
  * @param	string	$table		Table name
  * @param	mixed	$field		Column definition
  * @return	string|string[]
  */
 protected function _alter_table($alter_type, $table, $field)
 {
     if ($alter_type === 'DROP') {
         return parent::_alter_table($alter_type, $table, $field);
     }
     $sql = 'ALTER TABLE ' . $this->db->escape_identifiers($table);
     for ($i = 0, $c = count($field); $i < $c; $i++) {
         if ($field[$i]['_literal'] !== FALSE) {
             $field[$i] = $alter_type === 'ADD' ? "\n\tADD " . $field[$i]['_literal'] : "\n\tMODIFY " . $field[$i]['_literal'];
         } else {
             if ($alter_type === 'ADD') {
                 $field[$i]['_literal'] = "\n\tADD ";
             } else {
                 $field[$i]['_literal'] = empty($field[$i]['new_name']) ? "\n\tMODIFY " : "\n\tCHANGE ";
             }
             $field[$i] = $field[$i]['_literal'] . $this->_process_column($field[$i]);
         }
     }
     return array($sql . implode(',', $field));
 }
开发者ID:SaiAshirwadInformatia,项目名称:TaskTracker,代码行数:28,代码来源:mysql_forge.php

示例8: _alter_table

 /**
  * ALTER TABLE.
  *
  * @param string $alter_type ALTER type
  * @param string $table      Table name
  * @param mixed  $field      Column definition
  *
  * @return string|string[]
  */
 protected function _alter_table($alter_type, $table, $field)
 {
     if (in_array($alter_type, ['DROP', 'ADD'], true)) {
         return parent::_alter_table($alter_type, $table, $field);
     }
     $sql = 'ALTER TABLE ' . $this->db->escape_identifiers($table);
     $sqls = [];
     for ($i = 0, $c = count($field); $i < $c; $i++) {
         if ($field[$i]['_literal'] !== false) {
             return false;
         }
         if (isset($field[$i]['type'])) {
             $sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escape_identififers($field[$i]['name']) . ' TYPE ' . $field[$i]['type'] . $field[$i]['length'];
         }
         if (!empty($field[$i]['default'])) {
             $sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ' SET DEFAULT ' . $field[$i]['default'];
         }
         if (isset($field[$i]['null'])) {
             $sqls[] = 'UPDATE "RDB$RELATION_FIELDS" SET "RDB$NULL_FLAG" = ' . ($field[$i]['null'] === true ? 'NULL' : '1') . ' WHERE "RDB$FIELD_NAME" = ' . $this->db->escape($field[$i]['name']) . ' AND "RDB$RELATION_NAME" = ' . $this->db->escape($table);
         }
         if (!empty($field[$i]['new_name'])) {
             $sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ' TO ' . $this->db->escape_identifiers($field[$i]['new_name']);
         }
     }
     return $sqls;
 }
开发者ID:recca0120,项目名称:laraigniter,代码行数:35,代码来源:ibase_forge.php


注:本文中的CI_DB_forge::_alter_table方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。