2 require_once(
'./Services/Database/classes/QueryUtils/class.ilQueryUtils.php');
27 $query_fields_array =
array();
28 foreach ($fields as $field_name => $field) {
29 $query_fields_array[] = $this->db_instance->getFieldDefinition()->getDeclaration($field[
'type'], $field_name, $field);
32 $query_fields = implode(
', ', $query_fields_array);
35 $query_fields .=
', PRIMARY KEY (' . implode(
', ', array_keys(
$options[
'primary'])) .
')';
38 $query =
"CREATE TABLE $name ($query_fields)";
40 $options_strings =
array();
43 $options_strings[
'comment'] =
'COMMENT = ' . $this->
quote(
$options[
'comment'],
'text');
47 $options_strings[
'charset'] =
'DEFAULT CHARACTER SET ' .
$options[
'charset'];
49 $options_strings[
'charset'] .=
' COLLATE ' .
$options[
'collate'];
58 $options_strings[] =
"ENGINE = $type";
61 if (!empty($options_strings)) {
62 $query .=
' ' . implode(
' ', $options_strings);
76 public function in($field, $values, $negate =
false,
$type =
"")
78 if (count($values) == 0) {
81 return $negate ?
' 1=1 ' :
' 1=2 ';
85 $str = $field . (($negate) ?
" NOT" :
"") .
" IN (?" . str_repeat(
",?", count($values) - 1) .
")";
87 $str = $field . (($negate) ?
" NOT" :
"") .
" IN (";
89 foreach ($values as $v) {
107 return $this->db_instance->quote($value,
$type);
118 if (!count($values)) {
122 $concat =
' CONCAT(';
124 foreach ($values as $field_info) {
125 $val = $field_info[0];
132 $concat .=
'COALESCE(';
155 public function locate($a_needle, $a_string, $a_start_pos = 1)
157 $locate =
' STRPOS(SUBSTR(';
158 $locate .= $a_string;
160 $locate .= $a_start_pos;
162 $locate .= $a_needle;
164 $locate .= --$a_start_pos;
188 return $this->db_instance->quoteIdentifier($identifier);
211 if ($case_insensitive) {
212 return "UPPER(" .
$column .
") LIKE(UPPER(?))";
217 if ($case_insensitive) {
219 return " UPPER(" .
$column .
") LIKE(UPPER(" . $this->
quote($value,
'text') .
"))";
222 return " " .
$column .
" LIKE(" . $this->
quote($value,
'text') .
")";
243 $lock =
'LOCK TABLES ';
246 foreach ($tables as
$table) {
251 if (isset($table[
'sequence']) && $table[
'sequence']) {
252 $table_name = $this->db_instance->getSequenceName($table[
'name']);
254 $table_name = $table[
'name'];
257 $lock .= ($table_name .
' ');
259 if ($table[
'alias']) {
260 $lock .= ($table[
'alias'] .
' ');
263 switch ($table[
'type']) {
283 return 'UNLOCK TABLES';
295 if ($a_collation !=
"") {
296 $sql =
"CREATE DATABASE " . $a_name .
" CHARACTER SET " . $a_charset .
" COLLATE " . $a_collation;
298 $sql =
"CREATE DATABASE " . $a_name .
" CHARACTER SET " . $a_charset;
312 public function groupConcat($a_field_name, $a_seperator =
",", $a_order = null)
314 if ($a_order === null) {
315 $sql =
"STRING_AGG(" . $a_field_name .
", " . $this->
quote($a_seperator,
"text") .
")";
317 $sql =
"STRING_AGG(" . $a_field_name .
", " . $this->
quote($a_seperator,
"text") .
" ORDER BY " . $a_order .
")";
326 public function cast($a_field_name, $a_dest_type)
328 return "CAST({$a_field_name} AS " . $this->db_instance->getFieldDefinition()->getTypeDeclaration(
array(
"type" => $a_dest_type)) .
")";
groupConcat($a_field_name, $a_seperator=",", $a_order=null)
Class ilPDOStatement is a Wrapper Class for PDOStatement.
in($field, $values, $negate=false, $type="")
cast($a_field_name, $a_dest_type)
string
like($column, $type, $value="?", $case_insensitive=true)
Class ilDatabaseException.
createDatabase($a_name, $a_charset="utf8", $a_collation="")
locate($a_needle, $a_string, $a_start_pos=1)
concat(array $values, $allow_null=true)
free(ilPDOStatement $statement)
closeCursor()
Pdo allows for a manual closing of the cursor.
quoteIdentifier($identifier)
Create styles array
The data for the language used.
Class ilPostgresQueryUtils.
createTable($name, $fields, $options=array())
if(empty($password)) $table
quote($value, $type=null)
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options