コード例 #1
0
ファイル: MySqlSchemaFactory.php プロジェクト: dfba/schema
 protected function queryColumns(PDO $pdo, Table $table, $columns = null)
 {
     $parameters = [$table->getSchema()->getName(), $table->getName()];
     $conditions = $this->sqlIn($parameters, '`COLUMN_NAME`', $columns);
     $datetimePrecision = "NULL";
     if ($this->isServerVersionAtLeast($pdo, 5, 6, 4)) {
         $datetimePrecision = "`DATETIME_PRECISION`";
     }
     $columnResults = $this->executeSelectQuery($pdo, "SELECT\n\t\t\t\t`COLUMN_NAME` AS `name`,\n\t\t\t\t`COLUMN_DEFAULT` AS `defaultValue`,\n\t\t\t\t`IS_NULLABLE` AS `nullable`,\n\t\t\t\t`DATA_TYPE` AS `dataType`,\n\t\t\t\t`CHARACTER_MAXIMUM_LENGTH` AS `maximumLength`,\n\t\t\t\t`CHARACTER_SET_NAME` AS `characterSet`,\n\t\t\t\t`COLLATION_NAME` AS `collation`,\n\t\t\t\t`COLUMN_TYPE` AS `type`,\n\t\t\t\t`NUMERIC_PRECISION` AS `numericPrecision`,\n\t\t\t\t`NUMERIC_SCALE` AS `numericScale`,\n\t\t\t\t{$datetimePrecision} AS `datetimePrecision`,\n\t\t\t\t`EXTRA` AS `extra`,\n\t\t\t\t`COLUMN_COMMENT` AS `comment`\n\t\t\tFROM `INFORMATION_SCHEMA`.`COLUMNS`\n\t\t\tWHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND {$conditions}\n\t\t\tORDER BY `ORDINAL_POSITION` ASC", $parameters);
     $columnAttributes = [];
     foreach ($columnResults as $result) {
         $columnAttributes[] = $this->parseInformationSchemaColumn($result);
     }
     return $columnAttributes;
 }
コード例 #2
0
ファイル: SQLiteSchemaFactory.php プロジェクト: dfba/schema
 protected function queryColumns(PDO $pdo, Table $table, $columns = null)
 {
     $schemaName = $table->getSchema()->getName();
     $tableName = $table->getName();
     $columnResults = $this->executeSelectQuery($pdo, "PRAGMA " . $pdo->quote($schemaName) . ".table_info(" . $pdo->quote($tableName) . ")");
     $columnAttributes = [];
     foreach ($columnResults as $result) {
         $name = $result['name'];
         $dataType = strtolower($result['type']);
         if ($columns === null || in_array($name, $columns)) {
             $columnAttributes[] = ['name' => $name, 'dataType' => $dataType, 'nullable' => !$result['notnull'], 'defaultValue' => $result['dflt_value'], 'maximumLength' => $this->getMaximumLength($dataType), 'minimumValue' => $this->getMinimumValue($dataType), 'maximumValue' => $this->getMaximumValue($dataType), 'unsigned' => false, 'zerofill' => false, 'autoIncrement' => null, 'characterSet' => $table->getSchema()->getCharacterSet()];
         }
     }
     return $columnAttributes;
 }
コード例 #3
0
ファイル: SchemaFactory.php プロジェクト: dfba/schema
 protected function newColumn(Table $table, array $attributes = [])
 {
     return $table->newColumn($attributes);
 }