コード例 #1
0
ファイル: Indicies.php プロジェクト: addiks/phpsql
 protected function getInternalColumns()
 {
     if (is_null($this->columns)) {
         $this->columns = array();
         $keyLength = $this->getKeyLength();
         if (is_null($keyLength)) {
             throw new ErrorException("Cannot create meta-table-schema for indicies when no key-length is specified!");
         }
         $columnPage = new Column();
         for ($i = 1; $i <= 33; $i++) {
             $columnPage->setName("ref{$i}");
             $columnPage->setDataType(DataType::INT());
             $columnPage->setLength($keyLength);
             $columnPage->setExtraFlags(Column::EXTRA_PRIMARY_KEY);
             $this->columns[] = clone $columnPage;
             $columnPage->setName("val{$i}");
             $columnPage->setDataType(DataType::INT());
             $columnPage->setLength($keyLength);
             $columnPage->setExtraFlags(Column::EXTRA_PRIMARY_KEY);
             $this->columns[] = clone $columnPage;
             $columnPage->setName("row{$i}");
             $columnPage->setDataType(DataType::INT());
             $columnPage->setLength($keyLength);
             $columnPage->setExtraFlags(Column::EXTRA_PRIMARY_KEY);
             $this->columns[] = clone $columnPage;
         }
     }
     return $this->columns;
 }
コード例 #2
0
ファイル: Table.php プロジェクト: fewlines/component
 /**
  * Creates the column from a given array
  *
  * @param array $columns
  */
 public function setColumns($columns)
 {
     if (false == is_array($columns)) {
         return;
     }
     foreach ($columns as $name => $options) {
         $column = new Column();
         $type = $this->getOptionByKey("type", $options);
         $length = $this->getOptionByKey("length", $options);
         $notNull = $this->getOptionByKey("notNull", $options);
         $autoIncrement = $this->getOptionByKey("autoIncrement", $options);
         $index = $this->getOptionByKey("index", $options);
         $collate = $this->getOptionByKey("collate", $options);
         $column->setName($name);
         // Set all options if set
         if (false != $type) {
             $column->setType($type);
         }
         if (false != $length) {
             $column->setLength($length);
         }
         if (false != $notNull) {
             $column->setNotNull($notNull);
         }
         if (false != $autoIncrement) {
             $column->setAutoIncrement($autoIncrement);
         }
         if (false != $index) {
             $column->setIndex($index);
         }
         if (false != $collate) {
             $column->setCollate($collate);
         }
         // Add column
         $this->columns[] = $column;
     }
 }
コード例 #3
0
ファイル: Tables.php プロジェクト: addiks/phpsql
 protected function getInternalColumns()
 {
     $columns = array();
     $columnPage = new Column();
     $columnPage->setName("TABLE_CATALOG");
     $columnPage->setDataType(DataType::VARCHAR());
     $columnPage->setLength(512);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("TABLE_SCHEMA");
     $columnPage->setDataType(DataType::VARCHAR());
     $columnPage->setLength(64);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("TABLE_NAME");
     $columnPage->setDataType(DataType::VARCHAR());
     $columnPage->setLength(64);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("TABLE_TYPE");
     $columnPage->setDataType(DataType::VARCHAR());
     $columnPage->setLength(64);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("ENGINE");
     $columnPage->setDataType(DataType::VARCHAR());
     $columnPage->setLength(64);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("VERSION");
     $columnPage->setDataType(DataType::BIGINT());
     $columnPage->setLength(21);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("ROW_FORMAT");
     $columnPage->setDataType(DataType::VARCHAR());
     $columnPage->setLength(10);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("TABLE_ROWS");
     $columnPage->setDataType(DataType::BIGINT());
     $columnPage->setLength(21);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("AVG_ROW_LENGTH");
     $columnPage->setDataType(DataType::BIGINT());
     $columnPage->setLength(21);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("DATA_LENGTH");
     $columnPage->setDataType(DataType::BIGINT());
     $columnPage->setLength(21);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("MAX_DATA_LENGTH");
     $columnPage->setDataType(DataType::BIGINT());
     $columnPage->setLength(21);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("INDEX_LENGTH");
     $columnPage->setDataType(DataType::BIGINT());
     $columnPage->setLength(21);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("DATA_FREE");
     $columnPage->setDataType(DataType::BIGINT());
     $columnPage->setLength(21);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("AUTO_INCREMENT");
     $columnPage->setDataType(DataType::BIGINT());
     $columnPage->setLength(21);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("CREATE_TIME");
     $columnPage->setDataType(DataType::DATETIME());
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("UPDATE_TIME");
     $columnPage->setDataType(DataType::DATETIME());
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("CHECK_TIME");
     $columnPage->setDataType(DataType::DATETIME());
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("TABLE_COLLATION");
     $columnPage->setDataType(DataType::VARCHAR());
     $columnPage->setLength(32);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("CHECKSUM");
     $columnPage->setDataType(DataType::BIGINT());
     $columnPage->setLength(21);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("CREATE_OPTIONS");
     $columnPage->setDataType(DataType::VARCHAR());
     $columnPage->setLength(32);
     $columns[$columnPage->getName()] = clone $columnPage;
     $columnPage->setName("TABLE_COMMENT");
     $columnPage->setDataType(DataType::VARCHAR());
     $columnPage->setLength(32);
     $columns[$columnPage->getName()] = clone $columnPage;
     return $columns;
 }