2 require_once(
'./Services/Database/classes/QueryUtils/class.ilQueryUtils.php');
19 public function in($field, $values, $negate =
false,
$type =
"")
21 if (count($values) == 0) {
24 return $negate ?
' 1=1 ' :
' 1=2 ';
28 $str = $field . (($negate) ?
" NOT" :
"") .
" IN (?" . str_repeat(
",?", count($values) - 1) .
")";
30 $str = $field . (($negate) ?
" NOT" :
"") .
" IN (";
32 foreach ($values as $v) {
50 return $this->db_instance->quote($value,
$type);
61 if (!count($values)) {
67 foreach ($values as $field_info) {
68 $val = $field_info[0];
75 $concat .=
'COALESCE(';
98 public function locate($a_needle, $a_string, $a_start_pos = 1)
100 $locate =
' LOCATE( ';
101 $locate .= $a_needle;
103 $locate .= $a_string;
105 $locate .= $a_start_pos;
130 return $this->db_instance->quoteIdentifier($identifier);
146 if (empty($fields)) {
149 $query_fields_array =
array();
150 foreach ($fields as $field_name => $field) {
151 $query_fields_array[] = $this->db_instance->getFieldDefinition()->getDeclaration($field[
'type'], $field_name, $field);
154 $query_fields = implode(
', ', $query_fields_array);
157 $query_fields .=
', PRIMARY KEY (' . implode(
', ', array_keys(
$options[
'primary'])) .
')';
160 $query =
"CREATE TABLE $name ($query_fields)";
162 $options_strings =
array();
165 $options_strings[
'comment'] =
'COMMENT = ' . $this->
quote(
$options[
'comment'],
'text');
169 $options_strings[
'charset'] =
'DEFAULT CHARACTER SET ' .
$options[
'charset'];
171 $options_strings[
'charset'] .=
' COLLATE ' .
$options[
'collate'];
180 $options_strings[] =
"ENGINE = $type";
183 if (!empty($options_strings)) {
184 $query .=
' ' . implode(
' ', $options_strings);
210 if ($case_insensitive) {
211 return "UPPER(" .
$column .
") LIKE(UPPER(?))";
216 if ($case_insensitive) {
218 return " UPPER(" .
$column .
") LIKE(UPPER(" . $this->
quote($value,
'text') .
"))";
221 return " " .
$column .
" LIKE(" . $this->
quote($value,
'text') .
")";
242 $lock =
'LOCK TABLES ';
245 foreach ($tables as
$table) {
250 if (isset($table[
'sequence']) && $table[
'sequence']) {
251 $table_name = $this->db_instance->getSequenceName($table[
'name']);
253 $table_name = $table[
'name'];
256 $lock .= ($table_name .
' ');
258 if ($table[
'alias']) {
259 $lock .= ($table[
'alias'] .
' ');
262 switch ($table[
'type']) {
282 return 'UNLOCK TABLES';
294 if ($a_collation !=
"") {
295 $sql =
"CREATE DATABASE `" . $a_name .
"` CHARACTER SET " . $a_charset .
" COLLATE " . $a_collation;
297 $sql =
"CREATE DATABASE `" . $a_name .
"` CHARACTER SET " . $a_charset;
311 public function groupConcat($a_field_name, $a_seperator =
",", $a_order = null)
313 if ($a_order === null) {
314 $sql =
"GROUP_CONCAT(" . $a_field_name .
" SEPARATOR " . $this->
quote($a_seperator,
"text") .
")";
316 $sql =
"GROUP_CONCAT(" . $a_field_name .
" ORDER BY " . $a_order .
" SEPARATOR " . $this->
quote($a_seperator,
"text") .
")";
325 public function cast($a_field_name, $a_dest_type)
327 return $a_field_name;
quoteIdentifier($identifier)
locate($a_needle, $a_string, $a_start_pos=1)
quote($value, $type=null)
Class ilPDOStatement is a Wrapper Class for PDOStatement.
createTable($name, $fields, $options=array())
createDatabase($a_name, $a_charset="utf8", $a_collation="")
Class ilDatabaseException.
free(ilPDOStatement $statement)
groupConcat($a_field_name, $a_seperator=",", $a_order=null)
closeCursor()
Pdo allows for a manual closing of the cursor.
like($column, $type, $value="?", $case_insensitive=true)
Create styles array
The data for the language used.
cast($a_field_name, $a_dest_type)
string
concat(array $values, $allow_null=true)
in($field, $values, $negate=false, $type="")
if(empty($password)) $table
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options