ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMySQLAbstraction Class Reference

This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abstraction layer and full compliance mode support. More...

+ Collaboration diagram for ilMySQLAbstraction:

Public Member Functions

 __construct ()
 Constructor. More...
 
 setTestMode ($a_testmode)
 Set Test Mode. More...
 
 getTestMode ()
 Get Test Mode. More...
 
 performAbstraction ($a_table_name, $a_set_text_ts_fields_notnull_false=true)
 Converts an existing (MySQL) ILIAS table in an abstract table. More...
 
 countRecords ($a_table_name)
 Check number of records before and after. More...
 
 storeStep ($a_table, $a_step)
 Store performed step. More...
 
 replaceEmptyStringsWithNull ($a_table)
 Replace empty strings with null values. More...
 
 replaceEmptyDatesWithNull ($a_table)
 Replace empty dates with null. More...
 
 lowerCaseTableName ($a_table_name)
 Lower case table and field names. More...
 
 lowerCaseColumnNames ($a_table_name)
 lower case column names More...
 
 removeAutoIncrement ($a_table_name, $a_auto_inc_field)
 Remove auto_increment attribute of a field. More...
 
 removePrimaryKey ($a_table, $a_pk)
 Remove primary key from table. More...
 
 removeIndices ($a_table, $a_indices)
 Remove Indices. More...
 
 removeConstraints ($a_table, $a_constraints)
 Remove Constraints. More...
 
 alterTable ($a_table, $a_fields, $a_set_text_ts_fields_notnull_false=true, $pk="")
 Use abstract types as delivered by MDB2 to alter table and make it use only MDB2 known types. More...
 
 addPrimaryKey ($a_table, $a_pk)
 Add primary key. More...
 
 addIndices ($a_table, $a_indices)
 Add indices. More...
 
 addConstraints ($a_table, $a_constraints)
 Add constraints. More...
 
 fixIndexNames ($a_table)
 This is only used on tables that have already been abstracted but missed the "full treatment". More...
 
 addAutoIncrementSequence ($a_table, $a_auto_inc_field)
 Add autoincrement sequence. More...
 
 fixClobNotNull ($a_table)
 This is only used on tables that have already been abstracted but missed the "full treatment". More...
 
 fixDatetimeValues ($a_table)
 This is only used on tables that have already been abstracted but missed the "full treatment". More...
 

Data Fields

 $analyzer
 

Detailed Description

This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abstraction layer and full compliance mode support.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id
class.ilDBUpdate.php 18649 2009-01-21 09:59:23Z akill

Definition at line 14 of file class.ilMySQLAbstraction.php.

Constructor & Destructor Documentation

◆ __construct()

ilMySQLAbstraction::__construct ( )

Constructor.

Definition at line 21 of file class.ilMySQLAbstraction.php.

References $ilDB, and setTestMode().

22  {
23  global $ilDB;
24 
25  $this->il_db = $ilDB;
26  $this->manager = $ilDB->db->loadModule('Manager');
27  $this->reverse = $ilDB->db->loadModule('Reverse');
28  if (@is_file('../Services/Database/classes/class.ilDBAnalyzer.php'))
29  {
30  include_once '../Services/Database/classes/class.ilDBAnalyzer.php';
31  }
32  else
33  {
34  include_once './Services/Database/classes/class.ilDBAnalyzer.php';
35  }
36  $this->analyzer = new ilDBAnalyzer();
37  $this->setTestMode(false);
38  }
setTestMode($a_testmode)
Set Test Mode.
global $ilDB
This class gives all kind of DB information using the MDB2 manager and reverse module.
+ Here is the call graph for this function:

Member Function Documentation

◆ addAutoIncrementSequence()

ilMySQLAbstraction::addAutoIncrementSequence (   $a_table,
  $a_auto_inc_field 
)

Add autoincrement sequence.

Parameters
stringtable name
stringautoincrement field

Definition at line 633 of file class.ilMySQLAbstraction.php.

Referenced by performAbstraction().

634  {
635  if ($a_auto_inc_field != "")
636  {
637  $set = $this->il_db->query("SELECT MAX(`".strtolower($a_auto_inc_field)."`) ma FROM `".$a_table."`");
638  $rec = $this->il_db->fetchAssoc($set);
639  $next = $rec["ma"] + 1;
640  $this->il_db->createSequence($a_table, $next);
641  }
642  }
+ Here is the caller graph for this function:

◆ addConstraints()

ilMySQLAbstraction::addConstraints (   $a_table,
  $a_constraints 
)

Add constraints.

Parameters
stringtable name
arrayconstraints information

Definition at line 562 of file class.ilMySQLAbstraction.php.

Referenced by performAbstraction().

563  {
564  if (is_array($a_constraints))
565  {
566  $all_valid = true;
567 
568  foreach ($a_constraints as $c)
569  {
570  if (strlen($c["name"]) > 3)
571  {
572  $all_valid = false;
573  }
574  }
575 
576  $cnt = 1;
577  foreach ($a_constraints as $c)
578  {
579  if (is_array($c["fields"]))
580  {
581  if (!$all_valid)
582  {
583  $c["name"] = "c".$cnt;
584  }
585  $fields = array();
586  foreach ($c["fields"] as $f => $pos)
587  {
588  $fields[] = strtolower($f);
589  }
590  $this->il_db->addUniqueConstraint($a_table, $fields, strtolower($c["name"]));
591  $cnt++;
592  }
593  }
594  }
595  }
+ Here is the caller graph for this function:

◆ addIndices()

ilMySQLAbstraction::addIndices (   $a_table,
  $a_indices 
)

Add indices.

Parameters
stringtable name
arrayindices information

Definition at line 521 of file class.ilMySQLAbstraction.php.

Referenced by fixIndexNames(), and performAbstraction().

522  {
523  if (is_array($a_indices))
524  {
525  $all_valid = true;
526 
527  foreach ($a_indices as $index)
528  {
529  if (strlen($index["name"]) > 3)
530  {
531  $all_valid = false;
532  }
533  }
534 
535  $cnt = 1;
536  foreach ($a_indices as $index)
537  {
538  if (is_array($index["fields"]))
539  {
540  if (!$all_valid)
541  {
542  $index["name"] = "i".$cnt;
543  }
544  $fields = array();
545  foreach ($index["fields"] as $f => $pos)
546  {
547  $fields[] = strtolower($f);
548  }
549  $this->il_db->addIndex($a_table, $fields, strtolower($index["name"]), $index["fulltext"]);
550  $cnt++;
551  }
552  }
553  }
554  }
+ Here is the caller graph for this function:

◆ addPrimaryKey()

ilMySQLAbstraction::addPrimaryKey (   $a_table,
  $a_pk 
)

Add primary key.

Parameters
stringtable name
arrayprimary key information

Definition at line 502 of file class.ilMySQLAbstraction.php.

Referenced by performAbstraction().

503  {
504  if (is_array($a_pk["fields"]))
505  {
506  $fields = array();
507  foreach ($a_pk["fields"] as $f => $pos)
508  {
509  $fields[] = strtolower($f);
510  }
511  $this->il_db->addPrimaryKey($a_table, $fields);
512  }
513  }
+ Here is the caller graph for this function:

◆ alterTable()

ilMySQLAbstraction::alterTable (   $a_table,
  $a_fields,
  $a_set_text_ts_fields_notnull_false = true,
  $pk = "" 
)

Use abstract types as delivered by MDB2 to alter table and make it use only MDB2 known types.

Parameters
stringtable name
arrayfields information

Definition at line 391 of file class.ilMySQLAbstraction.php.

References $d, $r, getTestMode(), and MDB2\isError().

Referenced by performAbstraction().

392  {
393  $n_fields = array();
394  foreach ($a_fields as $field => $d)
395  {
396  $def = $this->reverse->getTableFieldDefinition($a_table, $field);
397  $this->il_db->handleError($def);
398  $best_alt = $this->analyzer->getBestDefinitionAlternative($def);
399  $def = $def[$best_alt];
400 
401  // remove "current_timestamp" default for timestamps (not supported)
402  if (strtolower($def["nativetype"]) == "timestamp" &&
403  strtolower($def["default"]) == "current_timestamp")
404  {
405  unset($def["default"]);
406  }
407 
408  if (strtolower($def["type"]) == "float")
409  {
410  unset($def["length"]);
411  }
412 
413  // remove all invalid attributes
414  foreach ($def as $k => $v)
415  {
416  if (!in_array($k, array("type", "default", "notnull", "length", "unsigned", "fixed")))
417  {
418  unset($def[$k]);
419  }
420  }
421 
422  // determine length for decimal type
423  if ($def["type"] == "decimal")
424  {
425  $l_arr = explode(",",$def["length"]);
426  $def["length"] = $l_arr[0];
427  }
428 
429  // remove lenght values for float
430  if ($def["type"] == "float")
431  {
432  unset($def["length"]);
433  }
434 
435  // set notnull to false for text/timestamp/date fields
436  if ($a_set_text_ts_fields_notnull_false && ($def["type"] == "text" ||
437  $def["type"] == "timestamp" || $def["type"] == "date") &&
438  (!is_array($pk) || !isset($field,$pk["fields"][$field])))
439  {
440  $def["notnull"] = false;
441  }
442 
443  // set unsigned to false for integers
444  if ($def["type"] == "integer")
445  {
446  $def["unsigned"] = false;
447  }
448 
449  // set notnull to false for blob and clob
450  if ($def["type"] == "blob" || $def["type"] == "clob")
451  {
452  $def["notnull"] = false;
453  }
454 
455  // remove "0000-00-00..." default values
456  if (($def["type"] == "timestamp" && $def["default"] == "0000-00-00 00:00:00") ||
457  ($def["type"] == "date" && $def["default"] == "0000-00-00"))
458  {
459  unset($def["default"]);
460  }
461 
462  $a = array();
463  foreach ($def as $k => $v)
464  {
465  $a[$k] = $v;
466  }
467  $def["definition"] = $a;
468 
469  $n_fields[$field] = $def;
470  }
471 
472  $changes = array(
473  "change" => $n_fields
474  );
475 //var_dump($n_fields);
476  if (!$this->getTestMode())
477  {
478  $r = $this->manager->alterTable($a_table, $changes, false);
479  }
480  else
481  {
482  $r = $this->manager->createTable(strtolower($a_table)."_copy", $n_fields);
483  }
484 
485  if (MDB2::isError($r))
486  {
487  //$err = "<br>Details: ".mysql_error();
488  var_dump($r);
489  }
490  else
491  {
492  return $r;
493  }
494  }
isError($data, $code=null)
Tell whether a value is a MDB2 error.
Definition: MDB2.php:594
$r
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countRecords()

ilMySQLAbstraction::countRecords (   $a_table_name)

Check number of records before and after.

Definition at line 196 of file class.ilMySQLAbstraction.php.

References $ilDB, and $res.

Referenced by performAbstraction().

197  {
198  global $ilDB;
199 
200  $st = $ilDB->prepare("SELECT count(*) AS cnt FROM `".$a_table_name."`");
201  $res = $ilDB->execute($st);
202  $rec = $ilDB->fetchAssoc($res);
203 
204  return $rec["cnt"];
205  }
global $ilDB
+ Here is the caller graph for this function:

◆ fixClobNotNull()

ilMySQLAbstraction::fixClobNotNull (   $a_table)

This is only used on tables that have already been abstracted but missed the "full treatment".

Definition at line 648 of file class.ilMySQLAbstraction.php.

649  {
650  if (!$this->il_db->tableExists($a_table))
651  {
652  return;
653  }
654  $all_valid = true;
655  $fields = $this->analyzer->getFieldInformation($a_table);
656  foreach ($fields as $name => $def)
657  {
658  if ($def["type"] == "clob" && $def["notnull"] == true)
659  {
660  $this->il_db->modifyTableColumn($a_table, $name, array("type" => "clob", "notnull" => false));
661  }
662  }
663  }

◆ fixDatetimeValues()

ilMySQLAbstraction::fixDatetimeValues (   $a_table)

This is only used on tables that have already been abstracted but missed the "full treatment".

Definition at line 669 of file class.ilMySQLAbstraction.php.

References $nd.

670  {
671  if (!$this->il_db->tableExists($a_table))
672  {
673  return;
674  }
675  $all_valid = true;
676  $fields = $this->analyzer->getFieldInformation($a_table);
677  foreach ($fields as $name => $def)
678  {
679  if ($def["type"] == "timestamp" &&
680  ($def["notnull"] == true || $def["default"] == "0000-00-00 00:00:00"))
681  {
682  $nd = array("type" => "timestamp", "notnull" => false);
683  if ($def["default"] == "0000-00-00 00:00:00")
684  {
685  $nd["default"] = null;
686  }
687  $this->il_db->modifyTableColumn($a_table, $name, $nd);
688  }
689  if ($def["type"] == "date" &&
690  ($def["notnull"] == true || $def["default"] == "0000-00-00"))
691  {
692  $nd = array("type" => "date", "notnull" => false);
693  if ($def["default"] == "0000-00-00")
694  {
695  $nd["default"] = null;
696  }
697  $this->il_db->modifyTableColumn($a_table, $name, $nd);
698  }
699  }
700  }
$nd
Definition: error.php:9

◆ fixIndexNames()

ilMySQLAbstraction::fixIndexNames (   $a_table)

This is only used on tables that have already been abstracted but missed the "full treatment".

Definition at line 601 of file class.ilMySQLAbstraction.php.

References addIndices().

602  {
603  if (!$this->il_db->tableExists($a_table))
604  {
605  return;
606  }
607  $all_valid = true;
608  $indices = $this->analyzer->getIndicesInformation($a_table);
609  foreach ($indices as $index)
610  {
611  if (strlen($index["name"]) > 3)
612  {
613  $all_valid = false;
614  }
615  }
616 
617  if (!$all_valid)
618  {
619  foreach($indices as $index)
620  {
621  $this->il_db->dropIndex($a_table, $index["name"]);
622  }
623  $this->addIndices($a_table, $indices);
624  }
625  }
addIndices($a_table, $a_indices)
Add indices.
+ Here is the call graph for this function:

◆ getTestMode()

ilMySQLAbstraction::getTestMode ( )

Get Test Mode.

Returns
boolean Test Mode

Definition at line 55 of file class.ilMySQLAbstraction.php.

Referenced by alterTable(), and performAbstraction().

56  {
57  return $this->testmode;
58  }
+ Here is the caller graph for this function:

◆ lowerCaseColumnNames()

ilMySQLAbstraction::lowerCaseColumnNames (   $a_table_name)

lower case column names

Definition at line 304 of file class.ilMySQLAbstraction.php.

References $ilDB, $result, and $row.

Referenced by performAbstraction().

305  {
306  global $ilDB;
307 
308  $result = mysql_query("SHOW COLUMNS FROM `".$a_table_name."`");
309  while ($row = mysql_fetch_assoc($result))
310  {
311  if ($row["Field"] != strtolower($row["Field"]))
312  {
313  $ilDB->renameTableColumn($a_table_name, $row["Field"], strtolower($row["Field"]));
314  }
315  }
316 
317  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ lowerCaseTableName()

ilMySQLAbstraction::lowerCaseTableName (   $a_table_name)

Lower case table and field names.

Parameters
stringtable name

Definition at line 288 of file class.ilMySQLAbstraction.php.

References $ilDB.

Referenced by performAbstraction().

289  {
290  global $ilDB;
291 
292  if ($a_table_name != strtolower($a_table_name))
293  {
294  // this may look strange, but it does not work directly
295  // (seems that mysql does not see no difference whether upper or lowercase characters are used
296  mysql_query("ALTER TABLE `".$a_table_name."` RENAME `".strtolower($a_table_name)."xxx"."`");
297  mysql_query("ALTER TABLE `".strtolower($a_table_name)."xxx"."` RENAME `".strtolower($a_table_name)."`");
298  }
299  }
global $ilDB
+ Here is the caller graph for this function:

◆ performAbstraction()

ilMySQLAbstraction::performAbstraction (   $a_table_name,
  $a_set_text_ts_fields_notnull_false = true 
)

Converts an existing (MySQL) ILIAS table in an abstract table.

This means the table conforms to the MDB2 field types, uses sequences instead of auto_increment.

Parameters
stringtable name

Definition at line 67 of file class.ilMySQLAbstraction.php.

References addAutoIncrementSequence(), addConstraints(), addIndices(), addPrimaryKey(), alterTable(), countRecords(), getTestMode(), lowerCaseColumnNames(), lowerCaseTableName(), removeAutoIncrement(), removeConstraints(), removeIndices(), removePrimaryKey(), replaceEmptyDatesWithNull(), replaceEmptyStringsWithNull(), and storeStep().

68  {
69  // to do: log this procedure
70 
71 
72  // count number of records at the beginning
73  $nr_rec = $this->countRecords($a_table_name);
74 
75  // convert table name to lowercase
76  if (!$this->getTestMode())
77  {
78  $this->lowerCaseTableName($a_table_name);
79  $a_table_name = strtolower($a_table_name);
80  $this->storeStep($a_table_name, 10);
81  }
82 
83  // get auto increment information
84  $auto_inc_field = $this->analyzer->getAutoIncrementField($a_table_name);
85 
86  // get primary key information
87  $pk = $this->analyzer->getPrimaryKeyInformation($a_table_name);
88 
89  // get indices information
90  $indices = $this->analyzer->getIndicesInformation($a_table_name);
91 
92  // get constraints information
93  $constraints = $this->analyzer->getConstraintsInformation($a_table_name);
94 
95  // get field information
96  $fields = $this->analyzer->getFieldInformation($a_table_name);
97 
98  if (!$this->getTestMode())
99  {
100  // remove auto increment
101  $this->removeAutoIncrement($a_table_name, $auto_inc_field, $fields);
102  $this->storeStep($a_table_name, 20);
103 
104  // remove primary key
105  $this->removePrimaryKey($a_table_name, $pk);
106  $this->storeStep($a_table_name, 30);
107 
108  // remove indices
109  $this->removeIndices($a_table_name, $indices);
110  $this->storeStep($a_table_name, 40);
111 
112  // remove constraints
113  $this->removeConstraints($a_table_name, $constraints);
114  $this->storeStep($a_table_name, 45);
115  }
116 
117  // alter table using mdb2 field types
118  $this->alterTable($a_table_name, $fields, $a_set_text_ts_fields_notnull_false, $pk);
119  if ($this->getTestMode())
120  {
121  $a_table_name = strtolower($a_table_name)."_copy";
122  }
123  else
124  {
125  $this->storeStep($a_table_name, 50);
126  }
127 
128  // lower case field names
129  $this->lowerCaseColumnNames($a_table_name);
130  if (!$this->getTestMode())
131  {
132  $this->storeStep($a_table_name, 60);
133  }
134 
135  // add primary key
136  $this->addPrimaryKey($a_table_name, $pk);
137  if (!$this->getTestMode())
138  {
139  $this->storeStep($a_table_name, 70);
140  }
141 
142  // add indices
143  $this->addIndices($a_table_name, $indices);
144  if (!$this->getTestMode())
145  {
146  $this->storeStep($a_table_name, 80);
147  }
148 
149  // add constraints
150  $this->addConstraints($a_table_name, $constraints);
151  if (!$this->getTestMode())
152  {
153  $this->storeStep($a_table_name, 85);
154  }
155 
156  // add "auto increment" sequence
157  if ($auto_inc_field != "")
158  {
159  $this->addAutoIncrementSequence($a_table_name, $auto_inc_field);
160  }
161  if (!$this->getTestMode())
162  {
163  $this->storeStep($a_table_name, 90);
164  }
165 
166  // replace empty strings with null values in text fields
167  $this->replaceEmptyStringsWithNull($a_table_name);
168  if (!$this->getTestMode())
169  {
170  $this->storeStep($a_table_name, 100);
171  }
172 
173  // replace empty "0000-00-00..." dates with null
174  $this->replaceEmptyDatesWithNull($a_table_name);
175  if (!$this->getTestMode())
176  {
177  $this->storeStep($a_table_name, 110);
178  }
179 
180  $nr_rec2 = $this->countRecords($a_table_name);
181 
182  if (!$this->getTestMode())
183  {
184  if ($nr_rec != $nr_rec2)
185  {
186  die("ilMySQLAbstraction: Unexpected difference in table record number, table '".$a_table_name."'.".
187  " Before: ".((int) $nr_rec).", After: ".((int) $nr_rec2).".");
188  }
189  }
190  }
lowerCaseColumnNames($a_table_name)
lower case column names
replaceEmptyStringsWithNull($a_table)
Replace empty strings with null values.
removeAutoIncrement($a_table_name, $a_auto_inc_field)
Remove auto_increment attribute of a field.
countRecords($a_table_name)
Check number of records before and after.
addAutoIncrementSequence($a_table, $a_auto_inc_field)
Add autoincrement sequence.
replaceEmptyDatesWithNull($a_table)
Replace empty dates with null.
storeStep($a_table, $a_step)
Store performed step.
alterTable($a_table, $a_fields, $a_set_text_ts_fields_notnull_false=true, $pk="")
Use abstract types as delivered by MDB2 to alter table and make it use only MDB2 known types...
lowerCaseTableName($a_table_name)
Lower case table and field names.
addIndices($a_table, $a_indices)
Add indices.
addPrimaryKey($a_table, $a_pk)
Add primary key.
removeIndices($a_table, $a_indices)
Remove Indices.
removeConstraints($a_table, $a_constraints)
Remove Constraints.
removePrimaryKey($a_table, $a_pk)
Remove primary key from table.
addConstraints($a_table, $a_constraints)
Add constraints.
+ Here is the call graph for this function:

◆ removeAutoIncrement()

ilMySQLAbstraction::removeAutoIncrement (   $a_table_name,
  $a_auto_inc_field 
)

Remove auto_increment attribute of a field.

Parameters
stringtable name
stringautoincrement field

Definition at line 325 of file class.ilMySQLAbstraction.php.

Referenced by performAbstraction().

326  {
327  if ($a_auto_inc_field != "")
328  {
329  $this->il_db->modifyTableColumn($a_table_name, $a_auto_inc_field, array());
330  }
331  }
+ Here is the caller graph for this function:

◆ removeConstraints()

ilMySQLAbstraction::removeConstraints (   $a_table,
  $a_constraints 
)

Remove Constraints.

Parameters
stringtable name
arrayconstraints information

Definition at line 370 of file class.ilMySQLAbstraction.php.

Referenced by performAbstraction().

371  {
372  if (is_array($a_constraints))
373  {
374  foreach($a_constraints as $c)
375  {
376  if ($c["type"] == "unique")
377  {
378  $this->il_db->query("ALTER TABLE `".$a_table."` DROP INDEX `".$c["name"]."`");
379  }
380  }
381  }
382  }
+ Here is the caller graph for this function:

◆ removeIndices()

ilMySQLAbstraction::removeIndices (   $a_table,
  $a_indices 
)

Remove Indices.

Parameters
stringtable name
arrayindices information

Definition at line 353 of file class.ilMySQLAbstraction.php.

Referenced by performAbstraction().

354  {
355  if (is_array($a_indices))
356  {
357  foreach($a_indices as $index)
358  {
359  $this->il_db->query("ALTER TABLE `".$a_table."` DROP INDEX `".$index["name"]."`");
360  }
361  }
362  }
+ Here is the caller graph for this function:

◆ removePrimaryKey()

ilMySQLAbstraction::removePrimaryKey (   $a_table,
  $a_pk 
)

Remove primary key from table.

Parameters
stringtable name
arrayprimary key information

Definition at line 339 of file class.ilMySQLAbstraction.php.

Referenced by performAbstraction().

340  {
341  if ($a_pk["name"] != "")
342  {
343  $this->il_db->dropPrimaryKey($a_table, $a_pk["name"]);
344  }
345  }
+ Here is the caller graph for this function:

◆ replaceEmptyDatesWithNull()

ilMySQLAbstraction::replaceEmptyDatesWithNull (   $a_table)

Replace empty dates with null.

Definition at line 243 of file class.ilMySQLAbstraction.php.

References $ilDB.

Referenced by performAbstraction().

244  {
245  global $ilDB;
246 
247  if (!$this->il_db->tableExists($a_table))
248  {
249  return;
250  }
251 
252  $fields = $this->analyzer->getFieldInformation($a_table);
253  $upfields = array();
254  foreach ($fields as $field => $def)
255  {
256  if ($def["type"] == "timestamp")
257  {
258  $upfields[] = $field;
259  }
260  }
261  foreach ($upfields as $uf)
262  {
263  $ilDB->query("UPDATE `".$a_table."` SET `".$uf."` = null WHERE `".$uf."` = '0000-00-00 00:00:00'");
264  }
265 
266  $upfields = array();
267  reset($fields);
268  foreach ($fields as $field => $def)
269  {
270  if ($def["type"] == "date")
271  {
272  $upfields[] = $field;
273  }
274  }
275  foreach ($upfields as $uf)
276  {
277  $ilDB->query("UPDATE `".$a_table."` SET `".$uf."` = null WHERE `".$uf."` = '0000-00-00'");
278  }
279 
280  }
global $ilDB
+ Here is the caller graph for this function:

◆ replaceEmptyStringsWithNull()

ilMySQLAbstraction::replaceEmptyStringsWithNull (   $a_table)

Replace empty strings with null values.

Definition at line 220 of file class.ilMySQLAbstraction.php.

References $ilDB.

Referenced by performAbstraction().

221  {
222  global $ilDB;
223 
224  $fields = $this->analyzer->getFieldInformation($a_table);
225  $upfields = array();
226  foreach ($fields as $field => $def)
227  {
228  if ($def["type"] == "text" &&
229  ($def["length"] >= 1 && $def["length"] <= 4000))
230  {
231  $upfields[] = $field;
232  }
233  }
234  foreach ($upfields as $uf)
235  {
236  $ilDB->query("UPDATE `".$a_table."` SET `".$uf."` = null WHERE `".$uf."` = ''");
237  }
238  }
global $ilDB
+ Here is the caller graph for this function:

◆ setTestMode()

ilMySQLAbstraction::setTestMode (   $a_testmode)

Set Test Mode.

Parameters
boolean$a_testmodeTest Mode

Definition at line 45 of file class.ilMySQLAbstraction.php.

Referenced by __construct().

46  {
47  $this->testmode = $a_testmode;
48  }
+ Here is the caller graph for this function:

◆ storeStep()

ilMySQLAbstraction::storeStep (   $a_table,
  $a_step 
)

Store performed step.

Definition at line 210 of file class.ilMySQLAbstraction.php.

Referenced by performAbstraction().

211  {
212  $st = $this->il_db->prepareManip("REPLACE INTO abstraction_progress (table_name, step)".
213  " VALUES (?,?)", array("text", "integer"));
214  $this->il_db->execute($st, array($a_table, $a_step));
215  }
+ Here is the caller graph for this function:

Field Documentation

◆ $analyzer

ilMySQLAbstraction::$analyzer

Definition at line 16 of file class.ilMySQLAbstraction.php.


The documentation for this class was generated from the following file: