Пример #1
0
 public function testIsValidShouldReturnFalseWhenStatementInvalidInformed()
 {
     $statements = ['`Lft` INTEGER NOT NULL,', 'invalid column,'];
     $statement = new Statement(new Collection(), new PrimaryKey(), new IntegrityValidator());
     $statement->run($statements);
     $this->assertFalse($statement->isValid());
 }
Пример #2
0
 public static function instantiate($query)
 {
     $outputArray = [];
     $query = trim(rtrim(ltrim(str_replace(';', '', $query), '('), ')'));
     preg_match_all("/\\s*([^\\(|^\\,][^\\,]+\\S+[^\\,|\\s])/i", $query, $outputArray);
     if (empty($outputArray[1])) {
         throw new InvalidQueryException($query, 'Invalid Query.');
     }
     $statements = $outputArray[1];
     $statement = new Statement(new Collection(), new PrimaryKey(), new IntegrityValidator());
     return $statement->run($statements);
 }
 protected function createInvalidStatement()
 {
     $statement = new Statement(new Collection(), new PrimaryKey(), new IntegrityValidator());
     $statement->run(['invalid column,', '`NAME` VARCHAR,', 'PRIMARY KEY (`ID`),']);
     return $statement;
 }