コード例 #1
0
ファイル: ForeignKeyController.php プロジェクト: cebe/chive
 public function actionUpdate()
 {
     $isSubmitted = false;
     $sql = false;
     $foreignKey = ForeignKey::model()->findBySql('SELECT * FROM KEY_COLUMN_USAGE ' . 'WHERE TABLE_SCHEMA = :tableSchema ' . 'AND TABLE_NAME = :tableName ' . 'AND COLUMN_NAME = :columnName ' . 'AND REFERENCED_TABLE_SCHEMA IS NOT NULL', array('tableSchema' => $this->schema, 'tableName' => $this->table, 'columnName' => $this->column));
     if (!$foreignKey) {
         $foreignKey = new ForeignKey();
         $foreignKey->TABLE_SCHEMA = $this->schema;
         $foreignKey->TABLE_NAME = $this->table;
         $foreignKey->COLUMN_NAME = $this->column;
     }
     if (isset($_POST['ForeignKey'])) {
         $foreignKey->attributes = $_POST['ForeignKey'];
         if ($foreignKey->getReferences() && ($sql = $foreignKey->save())) {
             $isSubmitted = true;
         } elseif (!$foreignKey->getReferences() && ($sql = $foreignKey->delete())) {
             $isSubmitted = true;
         }
     }
     CHtml::generateRandomIdPrefix();
     // Column data
     $columns = array('' => '');
     $tables = Table::model()->findAllByAttributes(array('TABLE_SCHEMA' => $this->schema));
     foreach ($tables as $table) {
         if (StorageEngine::check($table->ENGINE, StorageEngine::SUPPORTS_FOREIGN_KEYS)) {
             $columns[$table->TABLE_NAME] = array();
             foreach ($table->columns as $column) {
                 $columns[$table->TABLE_NAME][$this->schema . '.' . $table->TABLE_NAME . '.' . $column->COLUMN_NAME] = $column->COLUMN_NAME;
             }
         }
     }
     // "On-Actions"
     $onActions = array('' => '', 'CASCADE' => 'CASCADE', 'SET NULL' => 'SET NULL', 'NO ACTION' => 'NO ACTION', 'RESTRICT' => 'RESTRICT');
     $this->render('form', array('foreignKey' => $foreignKey, 'columns' => $columns, 'onActions' => $onActions, 'sql' => $sql, 'isSubmitted' => $isSubmitted));
 }
コード例 #2
0
ファイル: InformationController.php プロジェクト: cebe/chive
 /**
  * Shows all installed storage engines.
  */
 public function actionStorageEngines()
 {
     $engines = StorageEngine::model()->findAll();
     $this->render('storageEngines', array('engines' => $engines));
 }
コード例 #3
0
ファイル: TableController.php プロジェクト: cebe/chive
 /**
  * Updates a table.
  */
 public function actionUpdate()
 {
     $this->layout = false;
     $isSubmitted = false;
     $sql = false;
     $table = Table::model()->findByPk(array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->table));
     if (isset($_POST['Table'])) {
         $table->attributes = $_POST['Table'];
         $sql = $table->save();
         if ($sql) {
             $isSubmitted = true;
         }
     }
     $collations = Collation::model()->findAll(array('order' => 'COLLATION_NAME', 'select' => 'COLLATION_NAME, CHARACTER_SET_NAME AS collationGroup'));
     CHtml::generateRandomIdPrefix();
     $this->render('form', array('table' => $table, 'collations' => $collations, 'storageEngines' => StorageEngine::getSupportedEngines(), 'isSubmitted' => $isSubmitted, 'sql' => $sql));
 }
コード例 #4
0
ファイル: form.php プロジェクト: cebe/chive
	<table class="form">
		<colgroup>
			<col class="col1"/>
			<col class="col2" />
			<col class="col3" />
		</colgroup>
		<tbody>
			<tr>
				<td>
					<?php 
echo CHtml::activeLabel($table, 'optionPackKeys');
?>
				</td>
				<td colspan="2">
					<?php 
echo CHtml::activeDropDownList($table, 'optionPackKeys', StorageEngine::getPackKeyOptions());
?>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
echo CHtml::activeLabel($table, 'optionDelayKeyWrite');
?>
				</td>
				<td colspan="2">
					<?php 
echo CHtml::activeCheckBox($table, 'optionDelayKeyWrite');
?>
				</td>
			</tr>
コード例 #5
0
 /**
  * Returns all storage engines which are supported by the current server.
  *
  * @return	array				Array of supported StorageEngine objects
  */
 public static function getSupportedEngines()
 {
     return StorageEngine::model()->findAllByAttributes(array('Support' => array('YES', 'DEFAULT')));
 }
コード例 #6
0
ファイル: StorageEngineTest.php プロジェクト: cebe/chive
 /**
  * tests the return values of the getSupports* methods
  */
 public function testSupports()
 {
     $db_arr = array('MEMORY', 'BerkeleyDB', 'BLACKHOLE', 'EXAMPLE', 'ARCHIVE', 'CSV', 'ndbcluster', 'FEDERATED', 'MRG_MYISAM', 'ISAM');
     foreach ($db_arr as $db) {
         $se = StorageEngine::model()->findAllByAttributes(array('Engine' => $db));
         if (count($se) == 0) {
             continue;
         }
         $this->assertFalse($se[0]->getSupportsChecksum());
         $this->assertFalse($se[0]->getSupportsPackKeys());
         $this->assertFalse($se[0]->getSupportsDelayKeyWrite());
     }
     $se = StorageEngine::model()->findAllByAttributes(array('Engine' => 'MyISAM'));
     $this->assertTrue($se[0]->getSupportsChecksum());
     $this->assertTrue($se[0]->getSupportsPackKeys());
     $this->assertTrue($se[0]->getSupportsDelayKeyWrite());
     $se = StorageEngine::model()->findAllByAttributes(array('Engine' => 'InnoDB'));
     $this->assertFalse($se[0]->getSupportsChecksum());
     $this->assertFalse($se[0]->getSupportsPackKeys());
     $this->assertFalse($se[0]->getSupportsDelayKeyWrite());
 }