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
 /**
  * Loads the contains for a given Relation
  * @param Relation $relation
  */
 protected function loadContraintsForRelation(Relation $relation)
 {
     if ($relation->getName() === 'sys_order_item') {
         $a = 0;
     }
     $constraint_type = ['UNIQUE', 'PRIMARY KEY', 'FOREIGN KEY'];
     $tableConstQuery = new SelectStatement();
     $tableConstQuery->from('information_schema.table_constraints')->where(sqlstr('constraint_type')->inList($constraint_type, SQLString::STRING_RENDERER()))->andWhere(sqlstr('table_schema')->equalsTo(':table_schema'))->andWhere(sqlstr('table_name')->equalsTo(':table_name'));
     $tableConstQueryParams = array(':table_schema' => $relation->getSchemaName(), ':table_name' => $relation->getName());
     $constColumnQuery = new SelectStatement();
     $constColumnQuery->from('information_schema.constraint_column_usage')->where(sqlstr('table_schema')->equalsTo(':table_schema'))->andWhere(sqlstr('constraint_name')->equalsTo(':constraint_name'));
     foreach ($this->database->executeQuery($tableConstQuery, $tableConstQueryParams) as $tableConst) {
         $constColumnParams = array(':table_schema' => $tableConst['table_schema'], ':constraint_name' => $tableConst['constraint_name']);
         $constColumns = $this->database->executeQuery($constColumnQuery, $constColumnParams);
         foreach ($constColumns as $constColumn) {
             $relation->addKeyColumn($constColumn, $tableConst['constraint_type']);
         }
     }
 }