ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPluginDBUpdate Class Reference

Database Update class. More...

+ Inheritance diagram for ilPluginDBUpdate:
+ Collaboration diagram for ilPluginDBUpdate:

Public Member Functions

 ilPluginDBUpdate ($a_ctype, $a_cname, $a_slot_id, $a_pname, $a_db_handler, $tmp_flag, $a_db_prefix)
 constructor
 getFileForStep ($a_version)
 Get db update file name for db step.
 _DBUpdate ()
 destructor
 getCurrentVersion ()
 Get current DB version.
 setCurrentVersion ($a_version)
 Set current DB version.
 loadXMLInfo ()
 checkQuery ($q)
 This is a very simple check.
- Public Member Functions inherited from ilDBUpdate
 ilDBUpdate ($a_db_handler=0, $tmp_flag=false)
 constructor
 initStep ($i)
 Init Step.
 readDBUpdateFile ()
 readLastUpdateFile ()
 setRunningStatus ($a_nr)
 Set running status for a step.
 getRunningStatus ()
 Get running status.
 clearRunningStatus ()
 Clear running status.
 readFileVersion ()
 getFileVersion ()
 Get Version of file.
 execQuery ($db, $str)
 execute a query
 applyUpdate ($a_break=0)
 Apply update.
 applyUpdateNr ($nr, $hotfix=false)
 apply an update
 getDBVersionStatus ()
 getTables ()
 getTableStatus ($table)
 optimizeTables ($tables)
 getHotfixCurrentVersion ()
 Get current hotfix version.
 setHotfixCurrentVersion ($a_version)
 Set current hotfix version.
 getHotfixFileVersion ()
 Get current hotfix version.
 readHotfixFileVersion ($a_file_content)
 Set current hotfix version.
 readHotfixInfo ($a_force=false)
 Get status of hotfix file.
 hotfixAvailable ()
 Get status of hotfix file.
 applyHotfix ()
 Apply hotfix.

Additional Inherited Members

- Data Fields inherited from ilDBUpdate
 $DB_UPDATE_FILE
 db update file
 $currentVersion
 $fileVersion

Detailed Description

Database Update class.

Author
Peter Gabriel pgabr.nosp@m.iel@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
Id:
class.ilDBUpdate.php 15875 2008-02-03 13:56:32Z akill

Definition at line 12 of file class.ilPluginDBUpdate.php.

Member Function Documentation

ilPluginDBUpdate::_DBUpdate ( )

destructor

Returns
boolean

Reimplemented from ilDBUpdate.

Definition at line 87 of file class.ilPluginDBUpdate.php.

{
// this may be used in setup!?
// $this->db->disconnect();
}
ilPluginDBUpdate::checkQuery (   $q)

This is a very simple check.

Could be done better.

Reimplemented from ilDBUpdate.

Definition at line 135 of file class.ilPluginDBUpdate.php.

References $q.

{
if ((is_int(stripos($q, "create table")) || is_int(stripos($q, "alter table")) ||
is_int(stripos($q, "drop table")))
&& !is_int(stripos($q, $this->db_prefix)))
{
return "Plugin may only create or alter tables that use prefix ".
$this->db_prefix;
}
else
{
return true;
}
}
ilPluginDBUpdate::getCurrentVersion ( )

Get current DB version.

Reimplemented from ilDBUpdate.

Definition at line 96 of file class.ilPluginDBUpdate.php.

References ilDBUpdate\$currentVersion, and $q.

Referenced by ilPluginDBUpdate().

{
$q = "SELECT db_version FROM il_plugin ".
" WHERE component_type = ".$this->db->quote($this->ctype, "text").
" AND component_name = ".$this->db->quote($this->cname, "text").
" AND slot_id = ".$this->db->quote($this->slot_id, "text").
" AND name = ".$this->db->quote($this->pname, "text");
$set = $this->db->query($q);
$rec = $this->db->fetchAssoc($set);
$this->currentVersion = (int) $rec["db_version"];
}

+ Here is the caller graph for this function:

ilPluginDBUpdate::getFileForStep (   $a_version)

Get db update file name for db step.

Reimplemented from ilDBUpdate.

Definition at line 77 of file class.ilPluginDBUpdate.php.

Referenced by ilPluginDBUpdate().

{
return "dbupdate.php";
}

+ Here is the caller graph for this function:

ilPluginDBUpdate::ilPluginDBUpdate (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_pname,
  $a_db_handler,
  $tmp_flag,
  $a_db_prefix 
)

constructor

Definition at line 17 of file class.ilPluginDBUpdate.php.

References getCurrentVersion(), ilPlugin\getDBUpdateScriptName(), getFileForStep(), ilPluginSlot\lookupSlotName(), ilDBUpdate\readDBUpdateFile(), ilDBUpdate\readFileVersion(), and ilDBUpdate\readLastUpdateFile().

{
$this->db_prefix = $a_db_prefix;
// workaround to allow setup migration
if ($a_db_handler)
{
$this->db =& $a_db_handler;
if ($tmp_flag)
{
$this->PATH = "./";
}
else
{
$this->PATH = "../";
}
}
else
{
global $mySetup;
$this->db = $mySetup->db;
$this->PATH = "./";
}
$this->ctype = $a_ctype;
$this->cname = $a_cname;
$this->slot_id = $a_slot_id;
$this->pname = $a_pname;
include_once("./Services/Component/classes/class.ilPluginSlot.php");
$this->slot_name = ilPluginSlot::lookupSlotName($this->ctype,
$this->cname, $this->slot_id);
// get update file for current version
$updatefile = $this->getFileForStep($this->currentVersion + 1);
$this->current_file = $updatefile;
$this->DB_UPDATE_FILE = $this->PATH.
ilPlugin::getDBUpdateScriptName($this->ctype, $this->cname,
$this->slot_name, $this->pname);
//
// NOTE: multiple update files for plugins are not supported yet
//
$this->LAST_UPDATE_FILE = $this->PATH.
ilPlugin::getDBUpdateScriptName($this->ctype, $this->cname,
$this->slot_name, $this->pname);
$this->readDBUpdateFile();
$this->readFileVersion();
}

+ Here is the call graph for this function:

ilPluginDBUpdate::loadXMLInfo ( )

Reimplemented from ilDBUpdate.

Definition at line 126 of file class.ilPluginDBUpdate.php.

{
// to do: reload control structure information for plugin
return true;
}
ilPluginDBUpdate::setCurrentVersion (   $a_version)

Set current DB version.

Reimplemented from ilDBUpdate.

Definition at line 114 of file class.ilPluginDBUpdate.php.

References $q.

{
$q = "UPDATE il_plugin SET db_version = ".$this->db->quote((int) $a_version, "integer").
" WHERE component_type = ".$this->db->quote($this->ctype, "text").
" AND component_name = ".$this->db->quote($this->cname, "text").
" AND slot_id = ".$this->db->quote($this->slot_id, "text").
" AND name = ".$this->db->quote($this->pname, "text");
$this->db->manipulate($q);
$this->currentVersion = $a_version;
return true;
}

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