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


PHP DbHelper::generateColumnDefinition方法代码示例

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


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

示例1: safeUp

 /**
  * Any migration code in here is wrapped inside of a transaction.
  *
  * @return bool
  */
 public function safeUp()
 {
     if (!craft()->db->tableExists('searchindex')) {
         // Taking the scenic route here so we can get to MysqlSchema's $engine argument
         $table = DbHelper::addTablePrefix('searchindex');
         $columns = array('elementId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'attribute' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Varchar, 'maxLength' => 25, 'null' => false)), 'fieldId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'locale' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Locale, 'null' => false)), 'keywords' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Text, 'null' => false)));
         $this->execute(craft()->db->getSchema()->createTable($table, $columns, null, 'MyISAM'));
         // Give it a composite primary key
         $this->addPrimaryKey('searchindex', 'elementId,attribute,fieldId,locale');
         // Add the FULLTEXT index on `keywords`
         $this->execute('CREATE FULLTEXT INDEX ' . craft()->db->quoteTableName(DbHelper::getIndexName('searchindex', 'keywords')) . ' ON ' . craft()->db->quoteTableName($table) . ' ' . '(' . craft()->db->quoteColumnName('keywords') . ')');
         Craft::log('Successfully added the `searchindex` table with a fulltext index on `keywords`.', LogLevel::Info, true);
     } else {
         Craft::log('Tried to add the `searchindex` table, but it already exists.', LogLevel::Warning, true);
     }
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:22,代码来源:m130604_000000_create_searchindex.php

示例2: alterColumn

 /**
  * @param      $table
  * @param      $column
  * @param      $type
  * @param null $newName
  * @param null $after
  *
  * @return int
  */
 public function alterColumn($table, $column, $type, $newName = null, $after = null)
 {
     $table = $this->getConnection()->addTablePrefix($table);
     $type = DbHelper::generateColumnDefinition($type);
     return $this->setText($this->getConnection()->getSchema()->alterColumn($table, $column, $type, $newName, $after))->execute();
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:15,代码来源:DbCommand.php

示例3: _createSearchIndexTable

 /**
  * Creates the searchindex table.
  *
  * @return null
  */
 private function _createSearchIndexTable()
 {
     Craft::log('Creating the searchindex table.');
     // Taking the scenic route here so we can get to MysqlSchema's $engine argument
     $table = craft()->db->addTablePrefix('searchindex');
     $columns = array('elementId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'attribute' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Varchar, 'maxLength' => 25, 'null' => false)), 'fieldId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'locale' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Locale, 'null' => false)), 'keywords' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Text, 'null' => false)));
     craft()->db->createCommand()->setText(craft()->db->getSchema()->createTable($table, $columns, null, 'MyISAM'))->execute();
     // Give it a composite primary key
     craft()->db->createCommand()->addPrimaryKey('searchindex', 'elementId,attribute,fieldId,locale');
     // Add the FULLTEXT index on `keywords`
     craft()->db->createCommand()->setText('CREATE FULLTEXT INDEX ' . craft()->db->quoteTableName(craft()->db->getIndexName('searchindex', 'keywords')) . ' ON ' . craft()->db->quoteTableName($table) . ' ' . '(' . craft()->db->quoteColumnName('keywords') . ')')->execute();
     Craft::log('Finished creating the searchindex table.');
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:18,代码来源:InstallService.php


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