コード例 #1
0
 public function testLists()
 {
     $list = ["a", "a\na", "a\ra", "a\ta", "a\\a", "a\\'a", "a\"a"];
     $q = new SelectStatement();
     $q->from('table1')->selectCount()->where(sqlstr('col1')->inList($list, SQLString::STRING_RENDERER()));
     $count = self::$currentDatabase->executeScalar($q . '');
     $this->assertEquals(count($list), $count);
 }
コード例 #2
0
 public function testGroupBy()
 {
     $s = new SelectStatement();
     $s->from('table1')->selectCount(null, 'field1')->select('field1')->groupBy('field1')->groupBy('field2');
     $this->assertEquals('SELECT COUNT(field1), field1 FROM table1 GROUP BY field1, field2', $s . '');
 }
コード例 #3
0
 public function testNulls()
 {
     $s = new SelectStatement();
     $s->from('table1')->where(sqlstr('field1')->isNull())->andWhere(sqlstr('field2')->isNotNull())->selectAll();
     $this->assertEquals('SELECT * FROM table1 WHERE field1 IS NULL AND field2 IS NOT NULL', $s . '');
 }
コード例 #4
0
ファイル: SelectTest.php プロジェクト: blendsdk/blendengine
 public function testSelectCountWithAliasTest()
 {
     $s = new SelectStatement();
     $s->selectCount('numbers')->from('table1')->where(sqlstr('field1')->equalsTo(5));
     $this->assertEquals('SELECT COUNT(*) AS numbers FROM table1 WHERE field1 = 5', $s . '');
 }
コード例 #5
0
ファイル: SchemaReader.php プロジェクト: blendsdk/blendengine
 /**
  * Loads columns for a given relation
  * @param Relation $relation
  */
 protected function loadColumnsForRelation(Relation $relation)
 {
     $sql = new SelectStatement();
     $sql->from('information_schema.columns')->where(sqlstr('table_schema')->equalsTo(':table_schema'))->andWhere(sqlstr('table_name')->equalsTo(':table_name'));
     $params = [':table_schema' => $relation->getSchemaName(), ':table_name' => $relation->getName()];
     foreach ($this->database->executeQuery($sql, $params) as $record) {
         $column = new Column($record);
         $relation->addColumn($column);
     }
 }