ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDBPdoFieldDefinition.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
25 abstract class ilDBPdoFieldDefinition
26 {
27  public array $lobs;
28  public const DEFAULT_DECIMAL_PLACES = 2;
29  public const DEFAULT_TEXT_LENGTH = 4000;
30  public const DEFINITION_COLUMN_NAME = "/^[a-z]+[_a-z0-9]*$/";
31  public const DEFINITION_TABLE_NAME = "/^[a-z]+[_a-z0-9]*$/";
32  public const INDEX_FORMAT = '%s_idx';
33  public const SEQUENCE_COLUMNS_NAME = 'sequence';
34  public const SEQUENCE_FORMAT = '%s_seq';
35  public const T_BLOB = 'blob';
36  public const T_CLOB = 'clob';
37  public const T_DATE = 'date';
38  public const T_DATETIME = 'datetime';
39  public const T_FLOAT = 'float';
40  public const T_INTEGER = 'integer';
41  public const T_TEXT = 'text';
42  public const T_TIME = 'time';
43  public const T_TIMESTAMP = 'timestamp';
44  protected static \ilDBPdoFieldDefinition $instance;
48  public array $allowed_attributes_old = [
49  self::T_TEXT => ['length', 'notnull', 'default', 'fixed'],
50  self::T_INTEGER => ['length', 'notnull', 'default', 'unsigned'],
51  self::T_FLOAT => ['notnull', 'default'],
52  self::T_DATE => ['notnull', 'default'],
53  self::T_TIME => ['notnull', 'default'],
54  self::T_TIMESTAMP => ['notnull', 'default'],
55  self::T_CLOB => ['notnull', 'default'],
56  self::T_BLOB => ['notnull', 'default'],
57  ];
61  public array $allowed_attributes = [
62  "text" => ["length", "notnull", "default", "fixed"],
63  "integer" => ["length", "notnull", "default", "unsigned"],
64  "float" => ["notnull", "default"],
65  "date" => ["notnull", "default"],
66  "time" => ["notnull", "default"],
67  "timestamp" => ["notnull", "default"],
68  "clob" => ["length", "notnull", "default"],
69  "blob" => ["length", "notnull", "default"],
70  ];
71  protected \ilDBInterface $db_instance;
72  protected array $max_length = [
73  self::T_INTEGER => [1, 2, 3, 4, 8],
74  self::T_TEXT => 4000,
75  ];
79  protected array $available_types = [
80  self::T_TEXT,
81  self::T_INTEGER,
82  self::T_FLOAT,
83  self::T_DATE,
84  self::T_TIME,
85  self::T_TIMESTAMP,
86  self::T_CLOB,
87  self::T_BLOB,
88  ];
92  protected array $reserved_mysql = [
93  "ACCESSIBLE",
94  "ACCOUNT",
95  "ACTION",
96  "ADD",
97  "AFTER",
98  "AGAINST",
99  "AGGREGATE",
100  "ALGORITHM",
101  "ALL",
102  "ALTER",
103  "ALWAYS",
104  "ANALYSE",
105  "ANALYZE",
106  "AND",
107  "ANY",
108  "AS",
109  "ASC",
110  "ASCII",
111  "ASENSITIVE",
112  "AT",
113  "AUTHORS",
114  "AUTOEXTEND_SIZE",
115  "AUTO_INCREMENT",
116  "AVG",
117  "AVG_ROW_LENGTH",
118  "BACKUP",
119  "BEFORE",
120  "BEGIN",
121  "BETWEEN",
122  "BIGINT",
123  "BINARY",
124  "BINLOG",
125  "BIT",
126  "BLOB",
127  "BLOCK",
128  "BOOL",
129  "BOOLEAN",
130  "BOTH",
131  "BTREE",
132  "BY",
133  "BYTE",
134  "CACHE",
135  "CALL",
136  "CASCADE",
137  "CASCADED",
138  "CASE",
139  "CATALOG_NAME",
140  "CHAIN",
141  "CHANGE",
142  "CHANGED",
143  "CHANNEL",
144  "CHAR",
145  "CHARACTER",
146  "CHARSET",
147  "CHECK",
148  "CHECKSUM",
149  "CIPHER",
150  "CLASS_ORIGIN",
151  "CLIENT",
152  "CLOSE",
153  "COALESCE",
154  "CODE",
155  "COLLATE",
156  "COLLATION",
157  "COLUMN",
158  "COLUMNS",
159  "COLUMN_FORMAT",
160  "COLUMN_NAME",
161  "COMMENT",
162  "COMMIT",
163  "COMMITTED",
164  "COMPACT",
165  "COMPLETION",
166  "COMPRESSED",
167  "COMPRESSION",
168  "CONCURRENT",
169  "CONDITION",
170  "CONNECTION",
171  "CONSISTENT",
172  "CONSTRAINT",
173  "CONSTRAINT_CATALOG",
174  "CONSTRAINT_NAME",
175  "CONSTRAINT_SCHEMA",
176  "CONTAINS",
177  "CONTEXT",
178  "CONTINUE",
179  "CONTRIBUTORS",
180  "CONVERT",
181  "CPU",
182  "CREATE",
183  "CROSS",
184  "CUBE",
185  "CURRENT",
186  "CURRENT_DATE",
187  "CURRENT_TIME",
188  "CURRENT_TIMESTAMP",
189  "CURRENT_USER",
190  "CURSOR",
191  "CURSOR_NAME",
192  "DATA",
193  "DATABASE",
194  "DATABASES",
195  "DATAFILE",
196  "DATE",
197  "DATETIME",
198  "DAY",
199  "DAY_HOUR",
200  "DAY_MICROSECOND",
201  "DAY_MINUTE",
202  "DAY_SECOND",
203  "DEALLOCATE",
204  "DEC",
205  "DECIMAL",
206  "DECLARE",
207  "DEFAULT",
208  "DEFAULT_AUTH",
209  "DEFINER",
210  "DELAYED",
211  "DELAY_KEY_WRITE",
212  "DELETE",
213  "DESC",
214  "DESCRIBE",
215  "DES_KEY_FILE",
216  "DETERMINISTIC",
217  "DIAGNOSTICS",
218  "DIRECTORY",
219  "DISABLE",
220  "DISCARD",
221  "DISK",
222  "DISTINCT",
223  "DISTINCTROW",
224  "DIV",
225  "DO",
226  "DOUBLE",
227  "DROP",
228  "DUAL",
229  "DUMPFILE",
230  "DUPLICATE",
231  "DYNAMIC",
232  "EACH",
233  "ELSE",
234  "ELSEIF",
235  "ENABLE",
236  "ENCLOSED",
237  "ENCRYPTION",
238  "END",
239  "ENDS",
240  "ENGINE",
241  "ENGINES",
242  "ENUM",
243  "ERROR",
244  "ERRORS",
245  "ESCAPE",
246  "ESCAPED",
247  "EVENT",
248  "EVENTS",
249  "EVERY",
250  "EXCHANGE",
251  "EXECUTE",
252  "EXISTS",
253  "EXIT",
254  "EXPANSION",
255  "EXPIRE",
256  "EXPLAIN",
257  "EXPORT",
258  "EXTENDED",
259  "EXTENT_SIZE",
260  "FALSE",
261  "FAST",
262  "FAULTS",
263  "FETCH",
264  "FIELDS",
265  "FILE",
266  "FILE_BLOCK_SIZE",
267  "FILTER",
268  "FIRST",
269  "FIXED",
270  "FLOAT",
271  "FLOAT4",
272  "FLOAT8",
273  "FLUSH",
274  "FOLLOWS",
275  "FOR",
276  "FORCE",
277  "FOREIGN",
278  "FORMAT",
279  "FOUND",
280  "FROM",
281  "FULL",
282  "FULLTEXT",
283  "FUNCTION",
284  "GENERAL",
285  "GENERATED",
286  "GEOMETRY",
287  "GEOMETRYCOLLECTION",
288  "GET",
289  "GET_FORMAT",
290  "GLOBAL",
291  "GRANT",
292  "GRANTS",
293  "GROUP",
294  "GROUP_REPLICATION",
295  "HANDLER",
296  "HASH",
297  "HAVING",
298  "HELP",
299  "HIGH_PRIORITY",
300  "HOST",
301  "HOSTS",
302  "HOUR",
303  "HOUR_MICROSECOND",
304  "HOUR_MINUTE",
305  "HOUR_SECOND",
306  "IDENTIFIED",
307  "IF",
308  "IGNORE",
309  "IGNORE_SERVER_IDS",
310  "IMPORT",
311  "IN",
312  "INDEX",
313  "INDEXES",
314  "INFILE",
315  "INITIAL_SIZE",
316  "INNER",
317  "INOUT",
318  "INSENSITIVE",
319  "INSERT",
320  "INSERT_METHOD",
321  "INSTALL",
322  "INSTANCE",
323  "INT",
324  "INT1",
325  "INT2",
326  "INT3",
327  "INT4",
328  "INT8",
329  "INTEGER",
330  "INTERVAL",
331  "INTO",
332  "INVOKER",
333  "IO",
334  "IO_AFTER_GTIDS",
335  "IO_BEFORE_GTIDS",
336  "IO_THREAD",
337  "IPC",
338  "IS",
339  "ISOLATION",
340  "ISSUER",
341  "ITERATE",
342  "JOIN",
343  "JSON",
344  "KEY",
345  "KEYS",
346  "KEY_BLOCK_SIZE",
347  "KILL",
348  "LANGUAGE",
349  "LAST",
350  "LEADING",
351  "LEAVE",
352  "LEAVES",
353  "LEFT",
354  "LESS",
355  "LEVEL",
356  "LIKE",
357  "LIMIT",
358  "LINEAR",
359  "LINES",
360  "LINESTRING",
361  "LIST",
362  "LOAD",
363  "LOCAL",
364  "LOCALTIME",
365  "LOCALTIMESTAMP",
366  "LOCK",
367  "LOCKS",
368  "LOGFILE",
369  "LOGS",
370  "LONG",
371  "LONGBLOB",
372  "LONGTEXT",
373  "LOOP",
374  "LOW_PRIORITY",
375  "MASTER",
376  "MASTER_AUTO_POSITION",
377  "MASTER_BIND",
378  "MASTER_CONNECT_RETRY",
379  "MASTER_DELAY",
380  "MASTER_HEARTBEAT_PERIOD",
381  "MASTER_HOST",
382  "MASTER_LOG_FILE",
383  "MASTER_LOG_POS",
384  "MASTER_PASSWORD",
385  "MASTER_PORT",
386  "MASTER_RETRY_COUNT",
387  "MASTER_SERVER_ID",
388  "MASTER_SSL",
389  "MASTER_SSL_CA",
390  "MASTER_SSL_CAPATH",
391  "MASTER_SSL_CERT",
392  "MASTER_SSL_CIPHER",
393  "MASTER_SSL_CRL",
394  "MASTER_SSL_CRLPATH",
395  "MASTER_SSL_KEY",
396  "MASTER_SSL_VERIFY_SERVER_CERT",
397  "MASTER_TLS_VERSION",
398  "MASTER_USER",
399  "MATCH",
400  "MAXVALUE",
401  "MAX_CONNECTIONS_PER_HOUR",
402  "MAX_QUERIES_PER_HOUR",
403  "MAX_ROWS",
404  "MAX_SIZE",
405  "MAX_STATEMENT_TIME",
406  "MAX_UPDATES_PER_HOUR",
407  "MAX_USER_CONNECTIONS",
408  "MEDIUM",
409  "MEDIUMBLOB",
410  "MEDIUMINT",
411  "MEDIUMTEXT",
412  "MEMORY",
413  "MERGE",
414  "MESSAGE_TEXT",
415  "MICROSECOND",
416  "MIDDLEINT",
417  "MIGRATE",
418  "MINUTE",
419  "MINUTE_MICROSECOND",
420  "MINUTE_SECOND",
421  "MIN_ROWS",
422  "MOD",
423  "MODE",
424  "MODIFIES",
425  "MODIFY",
426  "MONTH",
427  "MULTILINESTRING",
428  "MULTIPOINT",
429  "MULTIPOLYGON",
430  "MUTEX",
431  "MYSQL_ERRNO",
432  "NAME",
433  "NAMES",
434  "NATIONAL",
435  "NATURAL",
436  "NCHAR",
437  "NDB",
438  "NDBCLUSTER",
439  "NEVER",
440  "NEW",
441  "NEXT",
442  "NO",
443  "NODEGROUP",
444  "NONBLOCKING",
445  "NONE",
446  "NOT",
447  "NO_WAIT",
448  "NO_WRITE_TO_BINLOG",
449  "NULL",
450  "NUMBER",
451  "NUMERIC",
452  "NVARCHAR",
453  "OFFSET",
454  "OLD_PASSWORD",
455  "ON",
456  "ONE",
457  "ONE_SHOT",
458  "ONLY",
459  "OPEN",
460  "OPTIMIZE",
461  "OPTIMIZER_COSTS",
462  "OPTION",
463  "OPTIONALLY",
464  "OPTIONS",
465  "OR",
466  "ORDER",
467  "OUT",
468  "OUTER",
469  "OUTFILE",
470  "OWNER",
471  "PACK_KEYS",
472  "PAGE",
473  "PARSER",
474  "PARSE_GCOL_EXPR",
475  "PARTIAL",
476  "PARTITION",
477  "PARTITIONING",
478  "PARTITIONS",
479  "PASSWORD",
480  "PHASE",
481  "PLUGIN",
482  "PLUGINS",
483  "PLUGIN_DIR",
484  "POINT",
485  "POLYGON",
486  "PORT",
487  "PRECEDES",
488  "PRECISION",
489  "PREPARE",
490  "PRESERVE",
491  "PREV",
492  "PRIMARY",
493  "PRIVILEGES",
494  "PROCEDURE",
495  "PROCESSLIST",
496  "PROFILE",
497  "PROFILES",
498  "PROXY",
499  "PURGE",
500  "QUARTER",
501  "QUERY",
502  "QUICK",
503  "RANGE",
504  "READ",
505  "READS",
506  "READ_ONLY",
507  "READ_WRITE",
508  "REAL",
509  "REBUILD",
510  "RECOVER",
511  "REDOFILE",
512  "REDO_BUFFER_SIZE",
513  "REDUNDANT",
514  "REFERENCES",
515  "REGEXP",
516  "RELAY",
517  "RELAYLOG",
518  "RELAY_LOG_FILE",
519  "RELAY_LOG_POS",
520  "RELAY_THREAD",
521  "RELEASE",
522  "RELOAD",
523  "REMOVE",
524  "RENAME",
525  "REORGANIZE",
526  "REPAIR",
527  "REPEAT",
528  "REPEATABLE",
529  "REPLACE",
530  "REPLICATE_DO_DB",
531  "REPLICATE_DO_TABLE",
532  "REPLICATE_IGNORE_DB",
533  "REPLICATE_IGNORE_TABLE",
534  "REPLICATE_REWRITE_DB",
535  "REPLICATE_WILD_DO_TABLE",
536  "REPLICATE_WILD_IGNORE_TABLE",
537  "REPLICATION",
538  "REQUIRE",
539  "RESET",
540  "RESIGNAL",
541  "RESTORE",
542  "RESTRICT",
543  "RESUME",
544  "RETURN",
545  "RETURNED_SQLSTATE",
546  "RETURNS",
547  "REVERSE",
548  "REVOKE",
549  "RIGHT",
550  "RLIKE",
551  "ROLLBACK",
552  "ROLLUP",
553  "ROTATE",
554  "ROUTINE",
555  "ROW",
556  "ROWS",
557  "ROW_COUNT",
558  "ROW_FORMAT",
559  "RTREE",
560  "SAVEPOINT",
561  "SCHEDULE",
562  "SCHEMA",
563  "SCHEMAS",
564  "SCHEMA_NAME",
565  "SECOND",
566  "SECOND_MICROSECOND",
567  "SECURITY",
568  "SELECT",
569  "SENSITIVE",
570  "SEPARATOR",
571  "SERIAL",
572  "SERIALIZABLE",
573  "SERVER",
574  "SESSION",
575  "SET",
576  "SHARE",
577  "SHOW",
578  "SHUTDOWN",
579  "SIGNAL",
580  "SIGNED",
581  "SIMPLE",
582  "SLAVE",
583  "SLOW",
584  "SMALLINT",
585  "SNAPSHOT",
586  "SOCKET",
587  "SOME",
588  "SONAME",
589  "SOUNDS",
590  "SOURCE",
591  "SPATIAL",
592  "SPECIFIC",
593  "SQL",
594  "SQLEXCEPTION",
595  "SQLSTATE",
596  "SQLWARNING",
597  "SQL_AFTER_GTIDS",
598  "SQL_AFTER_MTS_GAPS",
599  "SQL_BEFORE_GTIDS",
600  "SQL_BIG_RESULT",
601  "SQL_BUFFER_RESULT",
602  "SQL_CACHE",
603  "SQL_CALC_FOUND_ROWS",
604  "SQL_NO_CACHE",
605  "SQL_SMALL_RESULT",
606  "SQL_THREAD",
607  "SQL_TSI_DAY",
608  "SQL_TSI_HOUR",
609  "SQL_TSI_MINUTE",
610  "SQL_TSI_MONTH",
611  "SQL_TSI_QUARTER",
612  "SQL_TSI_SECOND",
613  "SQL_TSI_WEEK",
614  "SQL_TSI_YEAR",
615  "SSL",
616  "STACKED",
617  "START",
618  "STARTING",
619  "STARTS",
620  "STATS_AUTO_RECALC",
621  "STATS_PERSISTENT",
622  "STATS_SAMPLE_PAGES",
623  "STATUS",
624  "STOP",
625  "STORAGE",
626  "STORED",
627  "STRAIGHT_JOIN",
628  "STRING",
629  "SUBCLASS_ORIGIN",
630  "SUBJECT",
631  "SUBPARTITION",
632  "SUBPARTITIONS",
633  "SUPER",
634  "SUSPEND",
635  "SWAPS",
636  "SWITCHES",
637  "TABLE",
638  "TABLES",
639  "TABLESPACE",
640  "TABLE_CHECKSUM",
641  "TABLE_NAME",
642  "TEMPORARY",
643  "TEMPTABLE",
644  "TERMINATED",
645  "TEXT",
646  "THAN",
647  "THEN",
648  "TIME",
649  "TIMESTAMP",
650  "TIMESTAMPADD",
651  "TIMESTAMPDIFF",
652  "TINYBLOB",
653  "TINYINT",
654  "TINYTEXT",
655  "TO",
656  "TRAILING",
657  "TRANSACTION",
658  "TRIGGER",
659  "TRIGGERS",
660  "TRUE",
661  "TRUNCATE",
662  "TYPE",
663  "TYPES",
664  "UNCOMMITTED",
665  "UNDEFINED",
666  "UNDO",
667  "UNDOFILE",
668  "UNDO_BUFFER_SIZE",
669  "UNICODE",
670  "UNINSTALL",
671  "UNION",
672  "UNIQUE",
673  "UNKNOWN",
674  "UNLOCK",
675  "UNSIGNED",
676  "UNTIL",
677  "UPDATE",
678  "UPGRADE",
679  "USAGE",
680  "USE",
681  "USER",
682  "USER_RESOURCES",
683  "USE_FRM",
684  "USING",
685  "UTC_DATE",
686  "UTC_TIME",
687  "UTC_TIMESTAMP",
688  "VALIDATION",
689  "VALUE",
690  "VALUES",
691  "VARBINARY",
692  "VARCHAR",
693  "VARCHARACTER",
694  "VARIABLES",
695  "VARYING",
696  "VIEW",
697  "VIRTUAL",
698  "WAIT",
699  "WARNINGS",
700  "WEEK",
701  "WEIGHT_STRING",
702  "WHEN",
703  "WHERE",
704  "WHILE",
705  "WITH",
706  "WITHOUT",
707  "WORK",
708  "WRAPPER",
709  "WRITE",
710  "X509",
711  "XA",
712  "XID",
713  "XML",
714  "XOR",
715  "YEAR",
716  "YEAR_MONTH",
717  "ZEROFILL",
718  ];
722  protected array $reserved_postgres = array(
723  "ALL",
724  "ANALYSE",
725  "ANALYZE",
726  "AND",
727  "ANY",
728  "ARRAY",
729  "AS",
730  "ASC",
731  "ASYMMETRIC",
732  "AUTHORIZATION",
733  "BETWEEN",
734  "BINARY",
735  "BOTH",
736  "CASE",
737  "CAST",
738  "CHECK",
739  "COLLATE",
740  "COLUMN",
741  "CONSTRAINT",
742  "CREATE",
743  "CROSS",
744  "CURRENT_DATE",
745  "CURRENT_ROLE",
746  "CURRENT_TIME",
747  "CURRENT_TIMESTAMP",
748  "CURRENT_USER",
749  "DEFAULT",
750  "DEFERRABLE",
751  "DESC",
752  "DISTINCT",
753  "DO",
754  "ELSE",
755  "END",
756  "EXCEPT",
757  "FALSE",
758  "FOR",
759  "FOREIGN",
760  "FREEZE",
761  "FROM",
762  "FULL",
763  "GRANT",
764  "GROUP",
765  "HAVING",
766  "ILIKE",
767  "IN",
768  "INITIALLY",
769  "INNER",
770  "INTERSECT",
771  "INTO",
772  "IS",
773  "ISNULL",
774  "JOIN",
775  "LEADING",
776  "LEFT",
777  "LIKE",
778  "LIMIT",
779  "LOCALTIME",
780  "LOCALTIMESTAMP",
781  "NATURAL",
782  "NEW",
783  "NOT",
784  "NOTNULL",
785  "NULL",
786  "OFF",
787  "OFFSET",
788  "OLD",
789  "ON",
790  "ONLY",
791  "OR",
792  "ORDER",
793  "OUTER",
794  "OVERLAPS",
795  "PLACING",
796  "PRIMARY",
797  "REFERENCES",
798  "RETURNING",
799  "RIGHT",
800  "SELECT",
801  "SESSION_USER",
802  "SIMILAR",
803  "SOME",
804  "SYMMETRIC",
805  "TABLE",
806  "THEN",
807  "TO",
808  "TRAILING",
809  "TRUE",
810  "UNION",
811  "UNIQUE",
812  "USER",
813  "USING",
814  "VERBOSE",
815  "WHEN",
816  "WHERE",
817  "WITH",
818  );
822  protected ?\ilMySQLQueryUtils $query_utils = null;
823 
827  public function __construct(\ilDBInterface $ilDBInterface)
828  {
829  $this->db_instance = $ilDBInterface;
830  }
831 
832  protected function getQueryUtils(): \ilMySQLQueryUtils
833  {
834  if ($this->query_utils === null) {
835  $this->query_utils = new ilMySQLQueryUtils($this->db_instance);
836  }
837 
838  return $this->query_utils;
839  }
840 
841  protected array $valid_default_values = [
842  'text' => '',
843  'boolean' => true,
844  'integer' => 0,
845  'decimal' => 0.0,
846  'float' => 0.0,
847  'timestamp' => '1970-01-01 00:00:00',
848  'time' => '00:00:00',
849  'date' => '1970-01-01',
850  'clob' => '',
851  'blob' => '',
852  ];
853 
857  public function checkTableName(string $table_name): bool
858  {
859  if (!preg_match(self::DEFINITION_TABLE_NAME, $table_name)) {
860  throw new ilDatabaseException('Table name must only contain _a-z0-9 and must start with a-z.');
861  }
862 
863  if ($this->isReserved($table_name)) {
864  throw new ilDatabaseException("Invalid table name '" . $table_name . "' (Reserved Word).");
865  }
866 
867  if (stripos($table_name, "sys_") === 0) {
868  throw new ilDatabaseException("Invalid table name '" . $table_name . "'. Name must not start with 'sys_'.");
869  }
870 
871  if (strlen($table_name) > 22) {
872  throw new ilDatabaseException("Invalid table name '" . $table_name . "'. Maximum table identifer length is 22 bytes.");
873  }
874 
875  return true;
876  }
877 
878  public function isReserved(string $table_name): bool
879  {
880  return false;
881  }
882 
886  public function getAllReserved(): array
887  {
888  return $this->getReservedMysql();
889  }
890 
894  public function getReservedMysql(): array
895  {
896  return $this->reserved_mysql;
897  }
898 
902  public function setReservedMysql(array $reserved_mysql): void
903  {
904  $this->reserved_mysql = $reserved_mysql;
905  }
906 
907 
911  public function checkColumnName(string $column_name): bool
912  {
913  if (!preg_match("/^[a-z]+[_a-z0-9]*$/", $column_name)) {
914  throw new ilDatabaseException("Invalid column name '" . $column_name
915  . "'. Column name must only contain _a-z0-9 and must start with a-z.");
916  }
917 
918  if ($this->isReserved($column_name)) {
919  throw new ilDatabaseException("Invalid column name '" . $column_name . "' (Reserved Word).");
920  }
921 
922  if (stripos($column_name, "sys_") === 0) {
923  throw new ilDatabaseException("Invalid column name '" . $column_name . "'. Name must not start with 'sys_'.");
924  }
925 
926  if (strlen($column_name) > 30) {
927  throw new ilDatabaseException("Invalid column name '" . $column_name . "'. Maximum column identifer length is 30 bytes.");
928  }
929 
930  return true;
931  }
932 
936  public function checkIndexName(string $a_name): bool
937  {
938  if (!preg_match("/^[a-z]+[_a-z0-9]*$/", $a_name)) {
939  throw new ilDatabaseException("Invalid column name '" . $a_name . "'. Column name must only contain _a-z0-9 and must start with a-z.");
940  }
941 
942  if ($this->isReserved($a_name)) {
943  throw new ilDatabaseException("Invalid column name '" . $a_name . "' (Reserved Word).");
944  }
945 
946  if (strlen($a_name) > 3) {
947  throw new ilDatabaseException("Invalid index name '" . $a_name . "'. Maximum index identifer length is 3 bytes.");
948  }
949 
950  return true;
951  }
952 
956  public function checkColumnDefinition(array $a_def): bool
957  {
958  // check valid type
959  if (!in_array($a_def["type"], $this->getAvailableTypes(), true)) {
960  switch ($a_def["type"]) {
961  case "boolean":
962  throw new ilDatabaseException("Invalid column type '" . $a_def["type"] . "'. Use integer(1) instead.");
963 
964  case "decimal":
965  throw new ilDatabaseException("Invalid column type '" . $a_def["type"] . "'. Use float or integer instead.");
966 
967  default:
968  throw new ilDatabaseException("Invalid column type '" . $a_def["type"] . "'. Allowed types are: "
969  . implode(', ', $this->getAvailableTypes()));
970  }
971  }
972 
973  // check used attributes
974  $allowed_attributes = $this->getAllowedAttributes();
975  foreach (array_keys($a_def) as $k) {
976  if ($k !== "type" && !in_array($k, $allowed_attributes[$a_def["type"]], true)) {
977  throw new ilDatabaseException("Attribute '" . $k . "' is not allowed for column type '" . $a_def["type"] . "'.");
978  }
979  }
980 
981  // type specific checks
982  $max_length = $this->getMaxLength();
983  switch ($a_def["type"]) {
984  case self::T_TEXT:
985  if ((!isset($a_def["length"]) || $a_def["length"] < 1 || $a_def["length"] > $max_length[self::T_TEXT]) && isset($a_def["length"])) {
986  throw new ilDatabaseException("Invalid length '" . $a_def["length"] . "' for type text." . " Length must be >=1 and <= "
987  . $max_length[self::T_TEXT] . ".");
988  }
989  break;
990 
991  case self::T_INTEGER:
992  if (isset($a_def["length"]) && !in_array((int) $a_def["length"], $max_length[self::T_INTEGER], true)) {
993  throw new ilDatabaseException("Invalid length '" . $a_def["length"] . "' for type integer." . " Length must be "
994  . implode(', ', $max_length[self::T_INTEGER]) . " (bytes).");
995  }
996  if ($a_def["unsigned"] ?? null) {
997  throw new ilDatabaseException("Unsigned attribut must not be true for type integer.");
998  }
999  break;
1000  }
1001 
1002  return true;
1003  }
1004 
1005  public function isAllowedAttribute(string $attribute, string $type): bool
1006  {
1007  return in_array($attribute, $this->allowed_attributes[$type], true);
1008  }
1009 
1013  public function getAvailableTypes(): array
1014  {
1015  return $this->available_types;
1016  }
1017 
1021  public function setAvailableTypes(array $available_types): void
1022  {
1023  $this->available_types = $available_types;
1024  }
1025 
1029  public function getAllowedAttributes(): array
1030  {
1032  }
1033 
1037  public function setAllowedAttributes(array $allowed_attributes): void
1038  {
1039  $this->allowed_attributes = $allowed_attributes;
1040  }
1041 
1042  public function getMaxLength(): array
1043  {
1044  return $this->max_length;
1045  }
1046 
1047  public function setMaxLength(array $max_length): void
1048  {
1049  $this->max_length = $max_length;
1050  }
1051 
1052  protected function getDBInstance(): \ilDBInterface
1053  {
1054  return $this->db_instance;
1055  }
1056 
1060  public function getValidTypes(): array
1061  {
1062  $types = $this->valid_default_values;
1063  $db = $this->getDBInstance();
1064 
1065  if (!empty($db->options['datatype_map'])) {
1066  foreach ($db->options['datatype_map'] as $type => $mapped_type) {
1067  if (array_key_exists($mapped_type, $types)) {
1068  $types[$type] = $types[$mapped_type];
1069  } elseif (!empty($db->options['datatype_map_callback'][$type])) {
1070  $parameter = array('type' => $type, 'mapped_type' => $mapped_type);
1071  $default = call_user_func_array(
1072  $db->options['datatype_map_callback'][$type],
1073  array(&$db, __FUNCTION__, $parameter)
1074  );
1075  $types[$type] = $default;
1076  }
1077  }
1078  }
1079 
1080  return $types;
1081  }
1082 
1083 
1084 
1089  public function getDeclaration(string $type, string $name, $field)
1090  {
1091  $db = $this->getDBInstance();
1092 
1093  if (!empty($db->options['datatype_map'][$type])) {
1094  $type = $db->options['datatype_map'][$type];
1095  if (!empty($db->options['datatype_map_callback'][$type])) {
1096  $parameter = array('type' => $type, 'name' => $name, 'field' => $field);
1097 
1098  return call_user_func_array(
1099  $db->options['datatype_map_callback'][$type],
1100  array(&$db, __FUNCTION__, $parameter)
1101  );
1102  }
1103  $field['type'] = $type;
1104  }
1105 
1106  if (!method_exists($this, "get{$type}Declaration")) {
1107  throw new ilDatabaseException('type not defined: ' . $type);
1108  }
1109 
1110  return $this->{"get{$type}Declaration"}($name, $field);
1111  }
1112 
1113  public function getTypeDeclaration(array $field): string
1114  {
1115  $db = $this->getDBInstance();
1116 
1117  switch ($field['type']) {
1118  case 'text':
1119  $length = empty($field['length']) ? $db->options['default_text_field_length'] : $field['length'];
1120  $fixed = empty($field['fixed']) ? false : $field['fixed'];
1121  if ($fixed) {
1122  return $length ? 'CHAR(' . $length . ')' : 'CHAR(' . $db->options['default_text_field_length'] . ')';
1123  }
1124 
1125  return $length ? 'VARCHAR(' . $length . ')' : 'TEXT';
1126  case 'clob':
1127  case 'decimal':
1128  case 'float':
1129  case 'blob':
1130  return 'TEXT';
1131  case 'integer':
1132  case 'boolean':
1133  return 'INT';
1134  case 'date':
1135  return 'CHAR (' . strlen('YYYY-MM-DD') . ')';
1136  case 'time':
1137  return 'CHAR (' . strlen('HH:MM:SS') . ')';
1138  case 'timestamp':
1139  return 'CHAR (' . strlen('YYYY-MM-DD HH:MM:SS') . ')';
1140  }
1141 
1142  return '';
1143  }
1144 
1145  protected function getInternalDeclaration(string $name, array $field): string
1146  {
1147  $db = $this->getDBInstance();
1148 
1149  $name = $db->quoteIdentifier($name, true);
1150  $declaration_options = '';
1151  $fd = $db->getFieldDefinition();
1152  if ($fd !== null) {
1153  $declaration_options = $fd->getDeclarationOptions($field);
1154  }
1155 
1156  return $name . ' ' . $this->getTypeDeclaration($field) . $declaration_options;
1157  }
1158 
1162  protected function getDeclarationOptions(array $field): string
1163  {
1164  $charset = empty($field['charset']) ? '' : ' ' . $this->getCharsetFieldDeclaration($field['charset']);
1165 
1166  $default = '';
1167  if (array_key_exists('default', $field)) {
1168  if ($field['default'] === '') {
1169  $db = $this->getDBInstance();
1170 
1171  if (empty($field['notnull'])) {
1172  $field['default'] = null;
1173  } else {
1174  $valid_default_values = $this->getValidTypes();
1175  $field['default'] = $valid_default_values[$field['type']];
1176  }
1177  if ($field['default'] === ''
1178  && isset($db->options["portability"])
1179  && ($db->options['portability'] & 32)
1180  ) {
1181  $field['default'] = ' ';
1182  }
1183  }
1184  $default = ' DEFAULT ' . $this->quote($field['default'], $field['type']);
1185  } elseif (empty($field['notnull'])) {
1186  $default = ' DEFAULT NULL';
1187  }
1188 
1189  $notnull = empty($field['notnull']) ? '' : ' NOT NULL';
1190  // alex patch 28 Nov 2011 start
1191  if (isset($field["notnull"]) && $field['notnull'] === false) {
1192  $notnull = " NULL";
1193  }
1194  // alex patch 28 Nov 2011 end
1195 
1196  $collation = empty($field['collation']) ? '' : ' ' . $this->getCollationFieldDeclaration($field['collation']);
1197 
1198  return $charset . $default . $notnull . $collation;
1199  }
1200 
1201  protected function getCharsetFieldDeclaration(string $charset): string
1202  {
1203  return '';
1204  }
1205 
1206  protected function getCollationFieldDeclaration(string $collation): string
1207  {
1208  return '';
1209  }
1210 
1214  protected function getIntegerDeclaration(string $name, array $field): string
1215  {
1216  return $this->getInternalDeclaration($name, $field);
1217  }
1218 
1222  protected function getTextDeclaration(string $name, array $field): string
1223  {
1224  return $this->getInternalDeclaration($name, $field);
1225  }
1226 
1227  protected function getCLOBDeclaration(string $name, array $field): string
1228  {
1229  $db = $this->getDBInstance();
1230 
1231  $notnull = empty($field['notnull']) ? '' : ' NOT NULL';
1232  $name = $db->quoteIdentifier($name, true);
1233 
1234  return $name . ' ' . $this->getTypeDeclaration($field) . $notnull;
1235  }
1236 
1237  protected function getBLOBDeclaration(string $name, array $field): string
1238  {
1239  $db = $this->getDBInstance();
1240 
1241  $notnull = empty($field['notnull']) ? '' : ' NOT NULL';
1242  $name = $db->quoteIdentifier($name, true);
1243 
1244  return $name . ' ' . $this->getTypeDeclaration($field) . $notnull;
1245  }
1246 
1247  protected function getBooleanDeclaration(string $name, array $field): string
1248  {
1249  return $this->getInternalDeclaration($name, $field);
1250  }
1251 
1252  protected function getDateDeclaration(string $name, array $field): string
1253  {
1254  return $this->getInternalDeclaration($name, $field);
1255  }
1256 
1257  protected function getTimestampDeclaration(string $name, array $field): string
1258  {
1259  return $this->getInternalDeclaration($name, $field);
1260  }
1261 
1262  protected function getTimeDeclaration(string $name, array $field): string
1263  {
1264  return $this->getInternalDeclaration($name, $field);
1265  }
1266 
1267  protected function getFloatDeclaration(string $name, array $field): string
1268  {
1269  return $this->getInternalDeclaration($name, $field);
1270  }
1271 
1272  protected function getDecimalDeclaration(string $name, array $field): string
1273  {
1274  return $this->getInternalDeclaration($name, $field);
1275  }
1276 
1282  public function compareDefinition(array $current, array $previous): array
1283  {
1284  $type = empty($current['type']) ? null : $current['type'];
1285 
1286  if (!method_exists($this, "compare{$type}Definition")) {
1287  $db = $this->getDBInstance();
1288 
1289  if (!empty($db->options['datatype_map_callback'][$type])) {
1290  $parameter = array('current' => $current, 'previous' => $previous);
1291 
1292  return call_user_func_array(
1293  $db->options['datatype_map_callback'][$type],
1294  array(&$db, __FUNCTION__, $parameter)
1295  );
1296  }
1297 
1298  throw new ilDatabaseException('type "' . $current['type'] . '" is not yet supported');
1299  }
1300 
1301  if (empty($previous['type']) || $previous['type'] != $type) {
1302  return $current;
1303  }
1304 
1305  $change = $this->{"compare{$type}Definition"}($current, $previous);
1306 
1307  if ($previous['type'] != $type) {
1308  $change['type'] = true;
1309  }
1310 
1311  $previous_notnull = empty($previous['notnull']) ? false : $previous['notnull'];
1312  $notnull = empty($current['notnull']) ? false : $current['notnull'];
1313  if ($previous_notnull !== $notnull) {
1314  $change['notnull'] = true;
1315  }
1316 
1317  $alt = $previous_notnull ? '' : null;
1318  $previous_default = array_key_exists(
1319  'default',
1320  $previous
1321  ) ? $previous['default'] : $alt;
1322  $alt = $notnull ? '' : null;
1323  $default = array_key_exists('default', $current) ? $current['default'] : $alt;
1324  if ($previous_default !== $default) {
1325  $change['default'] = true;
1326  }
1327 
1328  return $change;
1329  }
1330 
1334  protected function compareIntegerDefinition(array $current, array $previous): array
1335  {
1336  $change = array();
1337  $previous_unsigned = empty($previous['unsigned']) ? false : $previous['unsigned'];
1338  $unsigned = empty($current['unsigned']) ? false : $current['unsigned'];
1339  if ($previous_unsigned != $unsigned) {
1340  $change['unsigned'] = true;
1341  }
1342  $previous_autoincrement = empty($previous['autoincrement']) ? false : $previous['autoincrement'];
1343  $autoincrement = empty($current['autoincrement']) ? false : $current['autoincrement'];
1344  if ($previous_autoincrement != $autoincrement) {
1345  $change['autoincrement'] = true;
1346  }
1347 
1348  return $change;
1349  }
1350 
1354  protected function compareTextDefinition(array $current, array $previous): array
1355  {
1356  $change = array();
1357  $previous_length = empty($previous['length']) ? 0 : $previous['length'];
1358  $length = empty($current['length']) ? 0 : $current['length'];
1359  if ($previous_length != $length) {
1360  $change['length'] = true;
1361  }
1362  $previous_fixed = empty($previous['fixed']) ? 0 : $previous['fixed'];
1363  $fixed = empty($current['fixed']) ? 0 : $current['fixed'];
1364  if ($previous_fixed != $fixed) {
1365  $change['fixed'] = true;
1366  }
1367 
1368  return $change;
1369  }
1370 
1374  protected function compareCLOBDefinition(array $current, array $previous): array
1375  {
1376  return $this->compareTextDefinition($current, $previous);
1377  }
1378 
1382  protected function compareBLOBDefinition(array $current, array $previous): array
1383  {
1384  return $this->compareTextDefinition($current, $previous);
1385  }
1386 
1387  protected function compareDateDefinition(array $current, array $previous): array
1388  {
1389  return array();
1390  }
1391 
1392  protected function compareTimeDefinition(array $current, array $previous): array
1393  {
1394  return array();
1395  }
1396 
1397  protected function compareTimestampDefinition(array $current, array $previous): array
1398  {
1399  return array();
1400  }
1401 
1402  protected function compareBooleanDefinition(array $current, array $previous): array
1403  {
1404  return array();
1405  }
1406 
1407  protected function compareFloatDefinition(array $current, array $previous): array
1408  {
1409  return array();
1410  }
1411 
1412  protected function compareDecimalDefinition(array $current, array $previous): array
1413  {
1414  return array();
1415  }
1416 
1420  public function quote($value, ?string $type = null, bool $quote = true, bool $escape_wildcards = false): string
1421  {
1422  return $this->getDBInstance()->quote($value, $type ?? '');
1423  }
1424 
1428  protected function quoteInteger($value, bool $quote, bool $escape_wildcards): int
1429  {
1430  return (int) $value;
1431  }
1432 
1433  protected function quoteText(string $value, bool $quote, bool $escape_wildcards): string
1434  {
1435  if (!$quote) {
1436  return $value;
1437  }
1438 
1439  $db = $this->getDBInstance();
1440 
1441  $value = $db->escape($value, $escape_wildcards);
1442 
1443  return "'" . $value . "'";
1444  }
1445 
1449  protected function readFile($value): string
1450  {
1451  $close = false;
1452  if (is_string($value) && preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) {
1453  $close = true;
1454  if ($match[1] === 'file://') {
1455  $value = $match[2];
1456  }
1457  // do not try to open urls
1458  #$value = @fopen($value, 'r');
1459  }
1460 
1461  if (is_resource($value)) {
1462  $db = $this->getDBInstance();
1463 
1464  $fp = $value;
1465  $value = '';
1466  while (!@feof($fp)) {
1467  $value .= @fread($fp, $db->options['lob_buffer_length']);
1468  }
1469  if ($close) {
1470  @fclose($fp);
1471  }
1472  }
1473 
1474  return $value;
1475  }
1476 
1480  protected function quoteLOB($value, bool $quote, bool $escape_wildcards): string
1481  {
1482  $value = $this->readFile($value);
1483 
1484  return $this->quoteText($value, $quote, $escape_wildcards);
1485  }
1489  protected function quoteCLOB($value, bool $quote, bool $escape_wildcards): string
1490  {
1491  return $this->quoteLOB($value, $quote, $escape_wildcards);
1492  }
1496  protected function quoteBLOB($value, bool $quote, bool $escape_wildcards): string
1497  {
1498  return $this->quoteLOB($value, $quote, $escape_wildcards);
1499  }
1500 
1501  protected function quoteBoolean(bool $value, bool $quote, bool $escape_wildcards): int
1502  {
1503  return ($value ? 1 : 0);
1504  }
1505 
1506  protected function quoteDate(string $value, bool $quote, bool $escape_wildcards): string
1507  {
1508  if ($value === 'CURRENT_DATE') {
1509  return 'CURRENT_DATE';
1510  }
1511 
1512  return $this->quoteText($value, $quote, $escape_wildcards);
1513  }
1514 
1518  protected function quoteTimestamp(int $value, bool $quote, bool $escape_wildcards): string
1519  {
1520  throw new ilDatabaseException("deprecated");
1521  }
1522 
1526  protected function quoteTime(int $value, bool $quote, bool $escape_wildcards): string
1527  {
1528  throw new ilDatabaseException("deprecated");
1529  }
1530 
1531  protected function quoteFloat(string $value, bool $quote, bool $escape_wildcards): ?string
1532  {
1533  if (preg_match('/^(.*)e([-+])(\d+)$/i', $value, $matches)) {
1534  $decimal = $this->quoteDecimal($matches[1], $quote, $escape_wildcards);
1535  $sign = $matches[2];
1536  $exponent = str_pad($matches[3], 2, '0', STR_PAD_LEFT);
1537  $value = $decimal . 'E' . $sign . $exponent;
1538  } else {
1539  $value = $this->quoteDecimal($value, $quote, $escape_wildcards);
1540  }
1541 
1542  return $value;
1543  }
1544 
1545  protected function quoteDecimal(string $value, bool $quote, bool $escape_wildcards): ?string
1546  {
1547  $value = preg_replace('/[^\d\.,\-+eE]/', '', $value);
1548  if (preg_match('/[^.0-9]/', $value) && strpos($value, ',')) {
1549  // 1000,00
1550  if (!strpos($value, '.')) {
1551  // convert the last "," to a "."
1552  $value = strrev(str_replace(',', '.', strrev($value)));
1553  // 1.000,00
1554  } elseif (strpos($value, '.') && strpos($value, '.') < strpos($value, ',')) {
1555  $value = str_replace('.', '', $value);
1556  // convert the last "," to a "."
1557  $value = strrev(str_replace(',', '.', strrev($value)));
1558  // 1,000.00
1559  } else {
1560  $value = str_replace(',', '', $value);
1561  }
1562  }
1563 
1564  return $value;
1565  }
1566 
1572  public function writeLOBToFile($lob, string $file): bool
1573  {
1574  $db = $this->getDBInstance();
1575 
1576  if (preg_match('/^(\w+:\/\/)(.*)$/', $file, $match) && $match[1] === 'file://') {
1577  $file = $match[2];
1578  }
1579 
1580  $fp = @fopen($file, 'wb');
1581  while (!@feof($lob)) {
1582  $result = @fread($lob, $db->options['lob_buffer_length']);
1583  $read = strlen($result);
1584  if (@fwrite($fp, $result, $read) !== $read) {
1585  @fclose($fp);
1586 
1587  throw new ilDatabaseException('could not write to the output file');
1588  }
1589  }
1590  @fclose($fp);
1591 
1592  return true;
1593  }
1594 
1595  protected function retrieveLOB(array &$lob): bool
1596  {
1597  if (is_null($lob['value'])) {
1598  $lob['value'] = $lob['resource'];
1599  }
1600  $lob['loaded'] = true;
1601 
1602  return true;
1603  }
1604 
1605  protected function readLOB(array $lob, int $length): string
1606  {
1607  return substr($lob['value'], $lob['position'], $length);
1608  }
1609 
1613  protected function endOfLOB(array $lob)
1614  {
1615  return $lob['endOfLOB'];
1616  }
1617 
1621  public function destroyLOB($lob): bool
1622  {
1623  $lob_data = stream_get_meta_data($lob);
1624  $lob_index = $lob_data['wrapper_data']->lob_index;
1625  fclose($lob);
1626  if (isset($this->lobs[$lob_index])) {
1627  unset($this->lobs[$lob_index]);
1628  }
1629 
1630  return true;
1631  }
1632 
1633 
1637  public function matchPattern(array $pattern, $operator = null, $field = null): string
1638  {
1639  $db = $this->getDBInstance();
1640 
1641  $match = '';
1642  if (!is_null($operator)) {
1643  $operator = strtoupper($operator);
1644  switch ($operator) {
1645  // case insensitive
1646  case 'ILIKE':
1647  if (is_null($field)) {
1648  throw new ilDatabaseException('case insensitive LIKE matching requires passing the field name');
1649  }
1650  $db->loadModule('Function');
1651  $match = $db->lower($field) . ' LIKE ';
1652  break;
1653  // case sensitive
1654  case 'LIKE':
1655  $match = is_null($field) ? 'LIKE ' : $field . ' LIKE ';
1656  break;
1657  default:
1658  throw new ilDatabaseException('not a supported operator type:' . $operator);
1659  }
1660  }
1661  $match .= "'";
1662  foreach ($pattern as $key => $value) {
1663  if ($key % 2 !== 0) {
1664  $match .= $value;
1665  } else {
1666  if ($operator === 'ILIKE') {
1667  $value = strtolower($value);
1668  }
1669  $escaped = $db->escape($value);
1670  $match .= $db->escapePattern($escaped);
1671  }
1672  }
1673  $match .= "'";
1674  $match .= $this->patternEscapeString();
1675 
1676  return $match;
1677  }
1678 
1679  public function patternEscapeString(): string
1680  {
1681  return '';
1682  }
1683 
1687  public function mapNativeDatatype(array $field)
1688  {
1689  $db = $this->getDBInstance();
1690  $db_type = strtok($field['type'], '(), ');
1691  if (!empty($db->options['nativetype_map_callback'][$db_type])) {
1692  return call_user_func_array($db->options['nativetype_map_callback'][$db_type], array($db, $field));
1693  }
1694 
1695  return $this->mapNativeDatatypeInternal($field);
1696  }
1697 
1701  abstract protected function mapNativeDatatypeInternal(array $field): array;
1702 
1706  public function mapPrepareDatatype(string $type)
1707  {
1708  $db = $this->getDBInstance();
1709 
1710  if (!empty($db->options['datatype_map'][$type])) {
1711  $type = $db->options['datatype_map'][$type];
1712  if (!empty($db->options['datatype_map_callback'][$type])) {
1713  $parameter = array('type' => $type);
1714 
1715  return call_user_func_array(
1716  $db->options['datatype_map_callback'][$type],
1717  array(&$db, __FUNCTION__, $parameter)
1718  );
1719  }
1720  }
1721 
1722  return $type;
1723  }
1724 }
compareIntegerDefinition(array $current, array $previous)
compareDecimalDefinition(array $current, array $previous)
compareBooleanDefinition(array $current, array $previous)
getIntegerDeclaration(string $name, array $field)
quoteBoolean(bool $value, bool $quote, bool $escape_wildcards)
compareTimeDefinition(array $current, array $previous)
isAllowedAttribute(string $attribute, string $type)
$type
quoteCLOB($value, bool $quote, bool $escape_wildcards)
quoteFloat(string $value, bool $quote, bool $escape_wildcards)
getTimeDeclaration(string $name, array $field)
compareDefinition(array $current, array $previous)
quoteInteger($value, bool $quote, bool $escape_wildcards)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getTextDeclaration(string $name, array $field)
array checkTableName(string $table_name)
compareCLOBDefinition(array $current, array $previous)
getTimestampDeclaration(string $name, array $field)
getInternalDeclaration(string $name, array $field)
quoteDecimal(string $value, bool $quote, bool $escape_wildcards)
setAvailableTypes(array $available_types)
mapNativeDatatypeInternal(array $field)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
quoteBLOB($value, bool $quote, bool $escape_wildcards)
if($format !==null) $name
Definition: metadata.php:247
quoteLOB($value, bool $quote, bool $escape_wildcards)
getFloatDeclaration(string $name, array $field)
compareTextDefinition(array $current, array $previous)
compareTimestampDefinition(array $current, array $previous)
getDecimalDeclaration(string $name, array $field)
string $key
Consumer key/client ID value.
Definition: System.php:193
compareFloatDefinition(array $current, array $previous)
setAllowedAttributes(array $allowed_attributes)
quoteText(string $value, bool $quote, bool $escape_wildcards)
getCLOBDeclaration(string $name, array $field)
getBooleanDeclaration(string $name, array $field)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
matchPattern(array $pattern, $operator=null, $field=null)
quoteTime(int $value, bool $quote, bool $escape_wildcards)
getDateDeclaration(string $name, array $field)
setReservedMysql(array $reserved_mysql)
quoteTimestamp(int $value, bool $quote, bool $escape_wildcards)
quoteDate(string $value, bool $quote, bool $escape_wildcards)
compareDateDefinition(array $current, array $previous)
quote($value, ?string $type=null, bool $quote=true, bool $escape_wildcards=false)
__construct(\ilDBInterface $ilDBInterface)
ilDBPdoFieldDefinition constructor.
compareBLOBDefinition(array $current, array $previous)
getDeclaration(string $type, string $name, $field)
getBLOBDeclaration(string $name, array $field)
getCollationFieldDeclaration(string $collation)
static ilDBPdoFieldDefinition $instance