CREATE TABLE {identifier} ( columndef, columndef, ... ); The syntax follows the official documentation below: http://www.sqlite.org/lang_createtable.html
 /**
  * @see https://github.com/c9s/LazyRecord/issues/94
  */
 public function testForIssue94()
 {
     $parser = new SqliteTableDefinitionParser('CREATE TABLE foo (`col4` text DEFAULT \'123\\\'\'\')');
     $def = $parser->parse();
     $this->assertNotNull($def);
     $this->assertEquals('foo', $def->tableName);
     $this->assertCount(1, $def->columns->columns);
     $this->assertEquals('col4', $def->columns->columns[0]->name);
     $this->assertEquals('TEXT', $def->columns->columns[0]->type);
     $this->assertEquals("123\\'", $def->columns->columns[0]->default);
 }
Esempio n. 2
0
 public function parseTableSql($table)
 {
     $sql = $this->getTableSql($table);
     if (preg_match('#`?(\\w+)`?\\s*\\((.*)\\)#ism', $sql, $regs)) {
         $columns = array();
         $name = $regs[1];
         $columnstr = $regs[2];
         $parser = new SqliteTableDefinitionParser($columnstr);
         $tableDef = $parser->parseColumnDefinitions();
         return $tableDef;
     }
 }