protected function findColumns($table) { // it may be good to use CUBRID PHP API to retrieve column info. $sql='SHOW COLUMNS FROM '.$table->rawName; try { $columns=$this->getDbConnection()->createCommand($sql)->queryAll(); } catch(Exception $e) { return false; } foreach($columns as $column) { $c=$this->createColumn($column); $table->columns[$c->name]=$c; } return true; }
protected function findConstraints($table) { $schemas=$this->getDbConnection()->getPdoInstance()->cubrid_schema(PDO::CUBRID_SCH_IMPORTED_KEYS,$table->name);
foreach($schemas as $schema) { $table->foreignKeys[$schema["FKCOLUMN_NAME"]]=array($schema["PKTABLE_NAME"],$schema["PKCOLUMN_NAME"]); if(isset($table->columns[$schema["FKCOLUMN_NAME"]])) $table->columns[$schema["FKCOLUMN_NAME"]]->isForeignKey=true; } }
Собрать данные о столбцах внешних ключей для заданной таблицы.
Собрать данные о столбцах первичного ключа для заданной таблицы.
findTableNames() метод
protected array findTableNames(string $schema='')
$schema
строка
схема таблиц. По умолчанию пустая строка, что означает текущую или стандартную схему. Если не пустая, возвращаемые имена таблиц будут с префиксом имени схемы.
protected function findTableNames($schema='') { // CUBRID does not allow to look into another database from within another connection. // If necessary user has to establish a connection to that particular database and // query to show all tables. For this reason if a user executes this funtion // we will return all table names of the currently connected database. return $this->getDbConnection()->createCommand('SHOW TABLES')->queryColumn(); }
public function resetSequence($table,$value=null) { if($table->sequenceName!==null) { if($value===null) $value=$this->getDbConnection()->createCommand("SELECT MAX(`{$table->primaryKey}`) FROM {$table->rawName}")->queryScalar()+1; else $value=(int)$value; $this->getDbConnection()->createCommand("ALTER TABLE {$table->rawName} AUTO_INCREMENT=$value")->execute(); } }
Сбрасывает значение последовательности первичного ключа таблицы. Последовательность будет сброшена таким образом, что первичный ключ следующей новой вставленной строки будет иметь указанное значение или 1.