61 $this->db =& $a_db_handler;
75 $this->db = $mySetup->db;
84 $this->current_file = $updatefile;
85 $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$updatefile;
90 $this->LAST_UPDATE_FILE = $this->PATH.
"setup/sql/dbupdate_02.php";
105 if ((
int)$a_version > 864)
107 return "dbupdate_02.php";
111 return "dbupdate.php";
122 $this->db->disconnect();
127 if (!file_exists($this->DB_UPDATE_FILE))
129 $this->error =
"no_db_update_file";
130 $this->filecontent = array();
134 $this->filecontent = @file($this->DB_UPDATE_FILE);
140 if (!file_exists($this->LAST_UPDATE_FILE))
142 $this->error =
"no_last_update_file";
143 $this->lastfilecontent = array();
147 $this->lastfilecontent = @file($this->LAST_UPDATE_FILE);
153 $q =
"SELECT value FROM settings ".
154 "WHERE keyword = 'db_version'";
155 $r = $this->db->query($q);
159 $this->currentVersion = (integer) $row->value;
161 return $this->currentVersion;
167 $q =
"UPDATE settings SET ".
168 "value = ".$this->db->quote($a_version).
" ".
169 "WHERE keyword = 'db_version'";
172 $this->db->query($q);
173 $this->currentVersion = $a_version;
181 reset($this->lastfilecontent);
183 foreach ($this->lastfilecontent as $row)
185 if (ereg(
"^<#([0-9]+)>", $row, $regs))
191 $this->fileVersion = (integer) $version;
211 $sql = explode(
"\n",trim($str));
212 for ($i=0; $i<count($sql); $i++)
214 $sql[$i] = trim($sql[$i]);
215 if ($sql[$i] !=
"" && substr($sql[$i],0,1)!=
"#")
218 if (substr($sql[$i],-1)==
";")
221 $q .=
" ".substr($sql[$i],0,-1);
226 if (MDB2::isError($r))
228 $this->error = $r->getMessage();
234 $this->error = $check;
247 echo
"incomplete_statement: ".$q.
"<br>";
274 for ($i=($c+1); $i<=$f; $i++)
279 $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$this->
getFileForStep($i);
286 "msg" =>
"update_error: ".$this->error,
289 $this->updateMsg = $msg;
295 "msg" =>
"update_applied",
301 $this->updateMsg = $msg;
305 $this->updateMsg =
"no_changes";
317 require_once
"./classes/class.ilModuleReader.php";
318 require_once
"./classes/class.ilServiceReader.php";
319 require_once
"./classes/class.ilCtrlStructureReader.php";
322 require_once
"./Services/Component/classes/class.ilModule.php";
323 require_once
"./Services/Component/classes/class.ilService.php";
329 foreach($modules as $module)
332 $module[
"subdir"],
"Modules");
338 foreach($services as $service)
341 $service[
"subdir"],
"Services");
346 $ilCtrlStructureReader->readStructure();
362 reset($this->filecontent);
368 while (!ereg(
"^<#".$nr.
">", $this->filecontent[$i]) && $i<count($this->filecontent))
374 if ($i == count($this->filecontent))
376 $this->error =
"update_not_found";
384 while ($i<count($this->filecontent) && !ereg(
"^<#".($nr+1).
">", $this->filecontent[$i]))
386 $update[] = trim($this->filecontent[$i]);
395 foreach ($update as $row)
397 if (ereg(
"<\?php", $row))
401 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
403 $this->error = $this->error;
410 elseif (ereg(
"\?>", $row))
414 eval(implode(
"\n", $php));
434 if ($mode ==
"sql" && count($sql) > 0)
436 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
438 $this->error =
"dump_error: ".$this->error;
453 if ($this->fileVersion > $this->currentVersion)
463 $query =
"SHOW TABLES";
464 $res = $this->db->query($query);
465 while ($row =
$res->fetchRow())
469 "name" => $status[
"Table"],
471 "status" => $status[
"Msg_text"]
481 $query =
"ANALYZE TABLE ".$table;
482 $res = $this->db->query($query);
490 foreach ($_POST[
"tables"] as $key => $value)
492 $query =
"OPTIMIZE TABLE ".$key;
493 $res = $this->db->query($query);
494 $msg[] =
"table $key: ok";