public function setUp() { $columnSchemaA = new ColumnSchema(); $columnSchemaA->setName("foo"); $columnSchemaA->setDataType(DataType::INTEGER()); $columnSchemaA->setLength(4); $columnSchemaA->setExtraFlags(ColumnSchema::EXTRA_PRIMARY_KEY); $columnSchemaB = new ColumnSchema(); $columnSchemaB->setName("baz"); $columnSchemaB->setDataType(DataType::VARCHAR()); $columnSchemaB->setLength(12); $columnSchemaC = new ColumnSchema(); $columnSchemaC->setName("bar"); $columnSchemaC->setDataType(DataType::DATETIME()); $columnSchemaC->setLength(19); $indexSchema = new IndexSchema(); $indexSchema->setName("idx_foo"); $indexSchema->setColumns([0]); # n'th index in $columnData's $indexSchema->setEngine(IndexEngine::BTREE()); $indexSchema->setType(Type::UNIQUE()); $indexSchema->setKeyLength(4); $tableSchema = new TableSchema(new FileResourceProxy(fopen("php://memory", "w")), new FileResourceProxy(fopen("php://memory", "w"))); $tableSchema->addColumnSchema($columnSchemaA); $tableSchema->addColumnSchema($columnSchemaB); $tableSchema->addColumnSchema($columnSchemaC); $tableSchema->addIndexSchema($indexSchema); $this->table = new Table($tableSchema, [new ColumnData(new FileResourceProxy(fopen("php://memory", "w")), $columnSchemaA), new ColumnData(new FileResourceProxy(fopen("php://memory", "w")), $columnSchemaB), new ColumnData(new FileResourceProxy(fopen("php://memory", "w")), $columnSchemaC)], [new BTree(new FileResourceProxy(fopen("php://memory", "w")), $tableSchema, $indexSchema)], new FileResourceProxy(fopen("php://memory", "w")), new FileResourceProxy(fopen("php://memory", "w"))); }
public function convertBinaryToString($binary, DataType $dataType) { switch ($dataType) { case DataType::BIT(): return $binary; case DataType::BOOL(): break; ### NUMERIC ### NUMERIC case DataType::TINYINT(): return (int) ord($binary); case DataType::SMALLINT(): case DataType::MEDIUMINT(): case DataType::INT(): case DataType::BIGINT(): return $this->strdec($binary); case DataType::DEC(): case DataType::FLOAT(): case DataType::DOUBLE(): return $binary; ### TIME / DATE ### TIME / DATE case DataType::DATE(): return date("Y-m-d", $this->strdec($binary)); case DataType::DATETIME(): return date("Y-m-d H:i:s", $this->strdec($binary)); case DataType::TIMESTAMP(): return date("Y-m-d H:i:s", $this->strdec($binary)); case DataType::TIME(): return date("H:i:s", $this->strdec($binary)); case DataType::YEAR(): return (string) $this->strdec($binary); ### TEXT ### TEXT case DataType::CHAR(): case DataType::VARCHAR(): case DataType::BINARY(): case DataType::VARBINARY(): case DataType::TINYBLOB(): case DataType::TINYTEXT(): case DataType::BLOB(): case DataType::TEXT(): case DataType::MEDIUMBLOB(): case DataType::MEDIUMTEXT(): case DataType::LONGBLOB(): case DataType::LONGTEXT(): case DataType::ENUM(): case DataType::SET(): return $binary; } }