Public Member Functions | |
ilDBx ($dsn) | |
constructor | |
_ilDBx () | |
destructor | |
disconnect () | |
disconnect from database | |
query ($sql) | |
query | |
quote ($a_query, $null_as_empty_string=true) | |
wrapper for quote method | |
getRow ($sql, $mode=DB_FETCHMODE_OBJECT) | |
getrow | |
getLastInsertId () | |
get last insert id | |
prepare ($query) | |
Wrapper for Pear prepare. | |
executeMultiple ($stmt, $data) | |
Wrapper for Pear executeMultiple. | |
execute ($stmt, $data) | |
Wrapper for Pear executeMultiple. | |
checkQuerySize ($a_query) | |
setMaxAllowedPacket () | |
_lockTables ($a_table_params) | |
Lock existing table. | |
_unlockTables () | |
getMySQLVersion () | |
get mysql version | |
isMysql4_1 () | |
check wether current MySQL server is version 4.1.x | |
isMysql4_1OrHigher () | |
check wether current MySQL server is version 4.1.x or higher NOTE: Please also see modules/dateplaner/classes/class.ilCalInterface.php->setNames if you make any changes here. | |
Data Fields | |
$error_class | |
$db | |
$result | |
$max_allowed_packet_size |
Definition at line 42 of file class.ilDBx.php.
ilDBx::_ilDBx | ( | ) |
destructor
Definition at line 117 of file class.ilDBx.php.
{ //$this->db->disconnect(); } //end destructor
ilDBx::_lockTables | ( | $ | a_table_params | ) |
Lock existing table.
array | (tablename => lock type READ, WRITE, READ LOCAL or LOW_PRIORITY) e.g array('tree' => 'WRITE') |
Definition at line 320 of file class.ilDBx.php.
References $counter, and $type.
Referenced by ilTree::deleteTree(), ilTree::insertNode(), ilTree::renumber(), and ilTree::saveSubTree().
{ global $ilDB; $lock_str = 'LOCK TABLES '; $counter = 0; foreach($a_table_params as $table_name => $type) { $lock_str .= $counter++ ? ',' : ''; $lock_str .= $table_name.' '.$type; } $ilDB->query($lock_str); return true; }
ilDBx::_unlockTables | ( | ) |
Definition at line 336 of file class.ilDBx.php.
Referenced by ilTree::deleteTree(), ilTree::insertNode(), and ilTree::renumber().
{ global $ilDB; $ilDB->query('UNLOCK TABLES'); return true; }
ilDBx::checkQuerySize | ( | $ | a_query | ) |
Definition at line 256 of file class.ilDBx.php.
References $lang.
{ global $lang; if(strlen($a_query) >= $this->max_allowed_packet_size) { return false; } else { return true; } }
ilDBx::disconnect | ( | ) |
disconnect from database
Definition at line 124 of file class.ilDBx.php.
{
// $this->db->disconnect();
}
ilDBx::execute | ( | $ | stmt, | |
$ | data | |||
) |
Wrapper for Pear executeMultiple.
resource | (statement from prepare) | |
array | multidim array of data |
Definition at line 242 of file class.ilDBx.php.
ilDBx::executeMultiple | ( | $ | stmt, | |
$ | data | |||
) |
Wrapper for Pear executeMultiple.
resource | (statement from prepare) | |
array | multidim array of data |
Definition at line 222 of file class.ilDBx.php.
ilDBx::getLastInsertId | ( | ) |
ilDBx::getMySQLVersion | ( | ) |
get mysql version
Definition at line 348 of file class.ilDBx.php.
{
return mysql_get_server_info();
}
ilDBx::getRow | ( | $ | sql, | |
$ | mode = DB_FETCHMODE_OBJECT | |||
) |
getrow
this is the wrapper itself. query a string, and return the resultobject, or in case of an error, jump to errorpage
string |
Definition at line 180 of file class.ilDBx.php.
{ $r = $this->db->getrow($sql,$mode); if (DB::isError($r)) { $this->raiseError($r->getMessage()."<br><font size=-1>SQL: ".$sql."</font>", $this->error_class->FATAL); } else { return $r; } } //end function
ilDBx::ilDBx | ( | $ | dsn | ) |
constructor
set up database conncetion and the errorhandling
string | dsn database-connection-string for pear-db |
Definition at line 77 of file class.ilDBx.php.
References isMysql4_1OrHigher(), query(), and setMaxAllowedPacket().
{ //call parent constructor $parent = get_parent_class($this); $this->$parent(); //set up error handling $this->error_class = new ilErrorHandling(); $this->setErrorHandling(PEAR_ERROR_CALLBACK, array($this->error_class,'errorHandler')); //check dsn if ($dsn=="") $this->raiseError("no DSN given", $this->error_class->FATAL); $this->dsn = $dsn; //connect to database $this->db = DB::connect($this->dsn, true); //check error if (DB::isError($this->db)) { $this->raiseError($this->db->getMessage(), $this->error_class->FATAL); } // SET 'max_allowed_packet' (only possible for mysql version 4) $this->setMaxAllowedPacket(); // set names // please also see modules/dateplaner/classes/class.ilCalInterface.php->setNames if ($this->isMysql4_1OrHigher()) { $this->query("SET NAMES utf8"); } return true; } //end constructor
ilDBx::isMysql4_1 | ( | ) |
check wether current MySQL server is version 4.1.x
Definition at line 356 of file class.ilDBx.php.
{ $version = explode(".", $this->getMysqlVersion()); if ($version[0] == "4" && $version[1] == "1") { return true; } return false; }
ilDBx::isMysql4_1OrHigher | ( | ) |
check wether current MySQL server is version 4.1.x or higher NOTE: Please also see modules/dateplaner/classes/class.ilCalInterface.php->setNames if you make any changes here.
Definition at line 373 of file class.ilDBx.php.
Referenced by ilDBx().
{ $version = explode(".", $this->getMysqlVersion()); if ((int)$version[0] >= 5 || ((int)$version[0] == 4 && (int)$version[1] >= 1)) { return true; } return false; }
ilDBx::prepare | ( | $ | query | ) |
Wrapper for Pear prepare.
String | query |
Definition at line 211 of file class.ilDBx.php.
References $query.
{ return $this->db->prepare($query); }
ilDBx::query | ( | $ | sql | ) |
query
this is the wrapper itself. query a string, and return the resultobject, or in case of an error, jump to errorpage
string |
Definition at line 138 of file class.ilDBx.php.
Referenced by getLastInsertId(), and ilDBx().
{ $r = $this->db->query($sql); if (DB::isError($r)) { $this->raiseError($r->getMessage()."<br><font size=-1>SQL: ".$sql."</font>", $this->error_class->FATAL); } else { return $r; } } //end function
ilDBx::quote | ( | $ | a_query, | |
$ | null_as_empty_string = true | |||
) |
wrapper for quote method
Definition at line 156 of file class.ilDBx.php.
{ if ($null_as_empty_string) { if ($a_query == "") { $a_query = ""; } } // maybe quoteSmart should be used in the future return $this->db->quote($a_query); }
ilDBx::setMaxAllowedPacket | ( | ) |
Definition at line 274 of file class.ilDBx.php.
References $query, $res, and $row.
Referenced by ilDBx().
{ // GET MYSQL VERSION $query = "SHOW VARIABLES LIKE 'version'"; $res = $this->db->query($query); if(DB::isError($res)) { $this->raiseError($res->getMessage()."<br><font size=-1>SQL: ".$query."</font>", $this->error_class->FATAL); } while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $version = $row->Value; } // CHANG VALUE IF MYSQL VERSION > 4.0 if(substr($version,0,1) == "4") { ini_get("post_max_size"); $query = "SET GLOBAL max_allowed_packet = ".(int) ini_get("post_max_size") * 1024 * 1024; $this->db->query($query); if(DB::isError($res)) { $this->raiseError($res->getMessage()."<br><font size=-1>SQL: ".$query."</font>", $this->error_class->FATAL); } } // STORE NEW max_size in member variable $query = "SHOW VARIABLES LIKE 'max_allowed_packet'"; if(DB::isError($res)) { $this->raiseError($res->getMessage()."<br><font size=-1>SQL: ".$query."</font>", $this->error_class->FATAL); } $res = $this->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $this->max_allowed_packet_size = $row->Value; } #var_dump("<pre>",$this->max_allowed_packet_size,"<pre>"); return true; }
ilDBx::$db |
Definition at line 55 of file class.ilDBx.php.
ilDBx::$error_class |
Definition at line 49 of file class.ilDBx.php.
ilDBx::$max_allowed_packet_size |
Definition at line 67 of file class.ilDBx.php.
ilDBx::$result |
Definition at line 61 of file class.ilDBx.php.