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


PHP Index::model方法代码示例

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


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

示例1: actionStructure

 /**
  * Shows the table structure
  */
 public function actionStructure()
 {
     $table = $this->loadTable();
     if (!$table instanceof Table) {
         $response = new AjaxResponse();
         $response->addNotification("error", Yii::t("core", "tableLoadErrorTitle", array("{table}" => $this->table)), Yii::t("core", "tableLoadErrorMessage", array("{table}" => $this->table)));
         $response->executeJavaScript("sideBar.loadTables(schema)");
         $this->sendJSON($response);
     }
     // Constraints
     if (StorageEngine::check($table->ENGINE, StorageEngine::SUPPORTS_FOREIGN_KEYS)) {
         $foreignKeys = array();
         $sql = 'SELECT * FROM KEY_COLUMN_USAGE ' . 'WHERE TABLE_SCHEMA = :tableSchema ' . 'AND TABLE_NAME = :tableName ' . 'AND REFERENCED_TABLE_SCHEMA IS NOT NULL';
         $table->foreignKeys = ForeignKey::model()->findAllBySql($sql, array('tableSchema' => $table->TABLE_SCHEMA, 'tableName' => $table->TABLE_NAME));
         foreach ($table->foreignKeys as $key) {
             $foreignKeys[] = $key->COLUMN_NAME;
         }
     } else {
         $foreignKeys = false;
     }
     // Indices
     $sql = 'SELECT * FROM STATISTICS ' . 'WHERE TABLE_SCHEMA = :tableSchema ' . 'AND TABLE_NAME = :tableName ' . 'GROUP BY INDEX_NAME ' . 'ORDER BY INDEX_NAME = \'PRIMARY\' DESC, INDEX_NAME';
     $table->indices = Index::model()->findAllBySql($sql, array('tableSchema' => $table->TABLE_SCHEMA, 'tableName' => $table->TABLE_NAME));
     foreach ($table->indices as $index) {
         $index->columns = IndexColumn::model()->findAllByAttributes(array('TABLE_SCHEMA' => $table->TABLE_SCHEMA, 'TABLE_NAME' => $table->TABLE_NAME, 'INDEX_NAME' => $index->INDEX_NAME));
     }
     // Indices (seperate for each column)
     $indicesRaw = Index::model()->findAllByAttributes(array('TABLE_SCHEMA' => $table->TABLE_SCHEMA, 'TABLE_NAME' => $table->TABLE_NAME));
     // Triggers
     $table->triggers = Trigger::model()->findAllByAttributes(array('EVENT_OBJECT_SCHEMA' => $table->TABLE_SCHEMA, 'EVENT_OBJECT_TABLE' => $table->TABLE_NAME));
     $this->render('structure', array('table' => $table, 'canAlter' => Yii::app()->user->privileges->checkTable($table->TABLE_SCHEMA, $table->TABLE_NAME, 'ALTER'), 'foreignKeys' => $foreignKeys, 'indicesRaw' => $indicesRaw));
 }
开发者ID:cebe,项目名称:chive,代码行数:35,代码来源:TableController.php

示例2: testUpdatePrimaryKey

 public function testUpdatePrimaryKey()
 {
     // Load index
     $index = Index::model()->findByAttributes(array('INDEX_NAME' => 'UNIQUE', 'TABLE_NAME' => 'table4', 'TABLE_SCHEMA' => 'indextest'));
     $index->setType('PRIMARY');
     // Try saving
     $index->save();
     // Reload index and load index columns
     $index->refresh();
     // Check properties
     $this->assertEquals('PRIMARY', $index->INDEX_NAME);
     $this->assertEquals('PRIMARY', $index->getType());
 }
开发者ID:cebe,项目名称:chive,代码行数:13,代码来源:IndexTest.php

示例3: actionDrop

 public function actionDrop()
 {
     // Get post vars
     $indexName = Yii::app()->request->getPost('index');
     $response = new AjaxResponse();
     try {
         $index = Index::model()->findByAttributes(array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->table, 'INDEX_NAME' => $indexName));
         $index->throwExceptions = true;
         $sql = $index->delete();
         $response->addNotification('success', Yii::t('core', 'successDropIndex', array('{index}' => $index->INDEX_NAME)), null, $sql);
         $response->addData('success', true);
     } catch (DbException $ex) {
         $response->addNotification('error', Yii::t('core', 'errorDropIndex', array('{index}' => $indexName)), $ex->getText(), $ex->getSql());
         $response->addData('success', false);
     }
     $this->sendJSON($response);
 }
开发者ID:cebe,项目名称:chive,代码行数:17,代码来源:IndexController.php


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