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


PHP DbHelper::addTablePrefix方法代碼示例

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


在下文中一共展示了DbHelper::addTablePrefix方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: _createSearchIndexTable

 /**
  * Creates the searchindex table.
  *
  * @access private
  */
 private function _createSearchIndexTable()
 {
     Craft::log('Creating the searchindex table.');
     // 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)));
     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(DbHelper::getIndexName('searchindex', 'keywords')) . ' ON ' . craft()->db->quoteTableName($table) . ' ' . '(' . craft()->db->quoteColumnName('keywords') . ')')->execute();
     Craft::log('Finished creating the searchindex table.');
 }
開發者ID:kentonquatman,項目名稱:portfolio,代碼行數:18,代碼來源:InstallService.php

示例3: tableExists

 /**
  * Returns whether a table exists.
  *
  * @param string $table
  * @param bool $refresh
  * @return bool
  */
 public function tableExists($table, $refresh = null)
 {
     // Default to refreshing the tables if Craft isn't installed yet
     if ($refresh || $refresh === null && !Craft::isInstalled()) {
         $this->getSchema()->refresh();
     }
     $table = DbHelper::addTablePrefix($table);
     return in_array($table, $this->getSchema()->getTableNames());
 }
開發者ID:kentonquatman,項目名稱:portfolio,代碼行數:16,代碼來源:DbConnection.php

示例4: _sqlSubSelect

 /**
  * Get SQL bit for sub-selects.
  *
  * @access private
  * @param string $where
  * @return string
  */
 private function _sqlSubSelect($where)
 {
     return sprintf("%s IN (SELECT %s FROM %s WHERE %s)", craft()->db->quoteColumnName('elementId'), craft()->db->quoteColumnName('elementId'), craft()->db->quoteTableName(DbHelper::addTablePrefix('searchindex')), $where);
 }
開發者ID:kentonquatman,項目名稱:portfolio,代碼行數:11,代碼來源:SearchService.php

示例5: dropPrimaryKey

 /**
  * @param string $table
  * @param string $columns
  * @return int
  */
 public function dropPrimaryKey($table, $columns)
 {
     $name = DbHelper::getPrimaryKeyName($table, $columns);
     $table = DbHelper::addTablePrefix($table);
     return parent::dropPrimaryKey($name, $table);
 }
開發者ID:kentonquatman,項目名稱:portfolio,代碼行數:11,代碼來源:DbCommand.php


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