protected function createTableInfo($tableName)
{
$tableName = str_replace("'", '', $tableName);
$this->getDbConnection()->setActive(true);
$table = $this->getDbConnection()->quoteString($tableName);
$sql = "PRAGMA table_info({$table})";
$command = $this->getDbConnection()->createCommand($sql);
$foreign = $this->getForeignKeys($table);
$index = 0;
$columns = array();
$primary = array();
foreach ($command->query() as $col) {
$col['index'] = $index++;
$column = $this->processColumn($col, $foreign);
$columns[$col['name']] = $column;
if ($column->getIsPrimaryKey()) {
$primary[] = $col['name'];
}
}
$info['TableName'] = $tableName;
if ($this->getIsView($tableName)) {
$info['IsView'] = true;
}
if (count($columns) === 0) {
throw new TDbException('dbmetadata_invalid_table_view', $tableName);
}
$class = $this->getTableInfoClass();
$tableInfo = new $class($info, $primary, $foreign);
$tableInfo->getColumns()->copyFrom($columns);
return $tableInfo;
}