public function setUp() { parent::setUp(); $fsql = new Environment(); $fsql->define_db('db1', parent::$tempDir); $schema = $fsql->get_database('db1')->getSchema('public'); $table = CachedTable::create($schema, 'blah', self::$columns); $this->sequence = new Identity($table, 'id'); }
public function testLikeIncluding() { $original = CachedTable::create($this->fsql->current_schema(), 'students', self::$columns1); $this->assertTrue($original !== false); $result = $this->fsql->query('CREATE TABLE people LIKE students INCLUDING IDENTITY INCLUDING DEFAULTS;'); $this->assertTrue($result); $table = $this->fsql->current_schema()->getTable('people'); $expected = array('id' => array('type' => 'i', 'auto' => 1, 'default' => 0, 'key' => 'p', 'null' => 0, 'restraint' => array(1, 0, 1, 1, 1, 10000, 0)), 'firstName' => array('type' => 's', 'auto' => 0, 'default' => null, 'key' => 'n', 'null' => 1, 'restraint' => array()), 'lastName' => array('type' => 's', 'auto' => 0, 'default' => 'blah', 'key' => 'n', 'null' => 0, 'restraint' => array()), 'zip' => array('type' => 'i', 'auto' => 0, 'default' => 12345, 'key' => 'n', 'null' => 0, 'restraint' => array()), 'gpa' => array('type' => 'f', 'auto' => 0, 'default' => 11000000.0, 'key' => 'n', 'null' => 0, 'restraint' => array())); $this->assertEquals($expected, $table->getColumns()); }
public function createTable($table_name, array $columns, $temporary = false) { if (!$temporary) { return CachedTable::create($this, $table_name, $columns); } else { $table = TempTable::create($this, $table_name, $columns); $this->loadedTables[$table_name] = $table; return $table; } }
public function testLimitCommas() { $table = CachedTable::create($this->fsql->current_schema(), 'customers', self::$columns1); foreach (self::$entries1 as $entry) { $table->insertRow($entry); } $table->commit(); $result = $this->fsql->query('SELECT * FROM customers LIMIT 3, 4'); $this->assertTrue($result !== false); $results = $this->fsql->fetch_all($result, ResultSet::FETCH_NUM); $this->assertEquals(array_slice(self::$entries1, 3, 4), $results); }
public function testNewCursor() { $table = CachedTable::create($this->schema, 'blah', self::$columns); $table->insertRow(self::$entries[0]); $table->insertRow(self::$entries[1]); $cursor = $table->newCursor(); $this->assertInstanceOf('FSQL\\Database\\TableCursor', $cursor); $this->assertTrue($cursor->valid()); $this->assertEquals(0, $cursor->key()); }