56 set_include_path(
"./Services/Database/lib/PEAR" . PATH_SEPARATOR . ini_get(
'include_path'));
57 if (!class_exists(
'PEAR')) {
58 require_once
'PEAR.php';
72 define(
'MDB2_OK',
true);
73 define(
'MDB2_ERROR', -1);
74 define(
'MDB2_ERROR_SYNTAX', -2);
75 define(
'MDB2_ERROR_CONSTRAINT', -3);
76 define(
'MDB2_ERROR_NOT_FOUND', -4);
77 define(
'MDB2_ERROR_ALREADY_EXISTS', -5);
78 define(
'MDB2_ERROR_UNSUPPORTED', -6);
79 define(
'MDB2_ERROR_MISMATCH', -7);
80 define(
'MDB2_ERROR_INVALID', -8);
81 define(
'MDB2_ERROR_NOT_CAPABLE', -9);
82 define(
'MDB2_ERROR_TRUNCATED', -10);
83 define(
'MDB2_ERROR_INVALID_NUMBER', -11);
84 define(
'MDB2_ERROR_INVALID_DATE', -12);
85 define(
'MDB2_ERROR_DIVZERO', -13);
86 define(
'MDB2_ERROR_NODBSELECTED', -14);
87 define(
'MDB2_ERROR_CANNOT_CREATE', -15);
88 define(
'MDB2_ERROR_CANNOT_DELETE', -16);
89 define(
'MDB2_ERROR_CANNOT_DROP', -17);
90 define(
'MDB2_ERROR_NOSUCHTABLE', -18);
91 define(
'MDB2_ERROR_NOSUCHFIELD', -19);
92 define(
'MDB2_ERROR_NEED_MORE_DATA', -20);
93 define(
'MDB2_ERROR_NOT_LOCKED', -21);
94 define(
'MDB2_ERROR_VALUE_COUNT_ON_ROW', -22);
95 define(
'MDB2_ERROR_INVALID_DSN', -23);
96 define(
'MDB2_ERROR_CONNECT_FAILED', -24);
97 define(
'MDB2_ERROR_EXTENSION_NOT_FOUND',-25);
98 define(
'MDB2_ERROR_NOSUCHDB', -26);
99 define(
'MDB2_ERROR_ACCESS_VIOLATION', -27);
100 define(
'MDB2_ERROR_CANNOT_REPLACE', -28);
101 define(
'MDB2_ERROR_CONSTRAINT_NOT_NULL',-29);
102 define(
'MDB2_ERROR_DEADLOCK', -30);
103 define(
'MDB2_ERROR_CANNOT_ALTER', -31);
104 define(
'MDB2_ERROR_MANAGER', -32);
105 define(
'MDB2_ERROR_MANAGER_PARSE', -33);
106 define(
'MDB2_ERROR_LOADMODULE', -34);
107 define(
'MDB2_ERROR_INSUFFICIENT_DATA', -35);
114 define(
'MDB2_PREPARE_MANIP',
false);
115 define(
'MDB2_PREPARE_RESULT', null);
124 define(
'MDB2_FETCHMODE_DEFAULT', 0);
129 define(
'MDB2_FETCHMODE_ORDERED', 1);
134 define(
'MDB2_FETCHMODE_ASSOC', 2);
139 define(
'MDB2_FETCHMODE_OBJECT', 3);
147 define(
'MDB2_FETCHMODE_FLIPPED', 4);
156 define(
'MDB2_PORTABILITY_NONE', 0);
163 define(
'MDB2_PORTABILITY_FIX_CASE', 1);
169 define(
'MDB2_PORTABILITY_RTRIM', 2);
175 define(
'MDB2_PORTABILITY_DELETE_COUNT', 4);
181 define(
'MDB2_PORTABILITY_NUMROWS', 8);
196 define(
'MDB2_PORTABILITY_ERRORS', 16);
203 define(
'MDB2_PORTABILITY_EMPTY_TO_NULL', 32);
209 define(
'MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES', 64);
215 define(
'MDB2_PORTABILITY_ALL', 127);
287 foreach (
$options as $option => $value) {
288 $test = $db->setOption($option, $value);
311 if (version_compare(phpversion(),
"5.0",
">=")) {
312 return class_exists($classname,
false);
314 return class_exists($classname);
333 $file_name = str_replace(
'_', DIRECTORY_SEPARATOR, $class_name).
'.php';
335 $include = include_once($file_name);
337 $include = @include_once($file_name);
341 $msg =
"unable to find package '$class_name' file '$file_name'";
343 $msg =
"unable to load class '$class_name' from file '$file_name'";
382 if (empty($dsninfo[
'phptype'])) {
384 null, null,
'no RDBMS driver specified');
387 $class_name =
'MDB2_Driver_'.$dsninfo[
'phptype'];
395 $db =
new $class_name();
396 $db->setDSN($dsninfo);
443 $err = $db->connect();
445 $dsn = $db->getDSN(
'string',
'xxx');
447 $err->addUserInfo($dsn);
490 $dsninfo = array_merge(
$GLOBALS[
'_MDB2_dsninfo_default'], $dsninfo);
495 if (count(array_diff_assoc($tmp_dsn, $dsninfo)) == 0) {
501 } elseif (is_array(
$GLOBALS[
'_MDB2_databases']) && reset(
$GLOBALS[
'_MDB2_databases'])) {
523 $file_name =
'MDB2'.DIRECTORY_SEPARATOR.$file.
'.php';
526 'unable to find: '.$file_name);
528 if (!include_once($file_name)) {
530 'unable to load driver class: '.$file_name);
601 if (is_a(
$data,
'MDB2_Error')) {
602 if (is_null(
$code)) {
604 } elseif (is_string(
$code)) {
628 return is_a($value,
'MDB2_Driver_Common');
645 return is_a($value,
'MDB2_Result');
662 return is_a($value,
'MDB2_Result_Common');
679 return is_a($value,
'MDB2_Statement');
699 static $errorMessages;
701 if (is_array($value)) {
702 $errorMessages = $value;
706 if (!isset($errorMessages)) {
707 $errorMessages =
array(
744 if (is_null($value)) {
745 return $errorMessages;
749 $value = $value->getCode();
752 return isset($errorMessages[$value]) ?
753 $errorMessages[$value] : $errorMessages[
MDB2_ERROR];
798 $parsed =
$GLOBALS[
'_MDB2_dsninfo_default'];
800 if (is_array($dsn)) {
801 $dsn = array_merge($parsed, $dsn);
802 if (!$dsn[
'dbsyntax']) {
803 $dsn[
'dbsyntax'] = $dsn[
'phptype'];
809 if (($pos = strpos($dsn,
'://')) !==
false) {
810 $str = substr($dsn, 0, $pos);
811 $dsn = substr($dsn, $pos + 3);
819 if (preg_match(
'|^(.+?)\((.*?)\)$|', $str, $arr)) {
820 $parsed[
'phptype'] = $arr[1];
821 $parsed[
'dbsyntax'] = !$arr[2] ? $arr[1] : $arr[2];
823 $parsed[
'phptype'] = $str;
824 $parsed[
'dbsyntax'] = $str;
833 if (($at = strrpos($dsn,
'@')) !==
false) {
834 $str = substr($dsn, 0, $at);
835 $dsn = substr($dsn, $at + 1);
836 if (($pos = strpos($str,
':')) !==
false) {
837 $parsed[
'username'] = rawurldecode(substr($str, 0, $pos));
838 $parsed[
'password'] = rawurldecode(substr($str, $pos + 1));
840 $parsed[
'username'] = rawurldecode($str);
847 if (preg_match(
'|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) {
849 $proto_opts = $match[2] ? $match[2] :
false;
854 if (strpos($dsn,
'+') !==
false) {
855 list($proto, $dsn) = explode(
'+', $dsn, 2);
857 if ( strpos($dsn,
'//') === 0
858 && strpos($dsn,
'/', 2) !==
false 859 && $parsed[
'phptype'] ==
'oci8' 866 } elseif (strpos($dsn,
'/') !==
false) {
867 list($proto_opts, $dsn) = explode(
'/', $dsn, 2);
875 $parsed[
'protocol'] = (!empty($proto)) ? $proto :
'tcp';
876 $proto_opts = rawurldecode($proto_opts);
877 if (strpos($proto_opts,
':') !==
false) {
878 list($proto_opts, $parsed[
'port']) = explode(
':', $proto_opts);
880 if ($parsed[
'protocol'] ==
'tcp') {
881 $parsed[
'hostspec'] = $proto_opts;
882 } elseif ($parsed[
'protocol'] ==
'unix') {
883 $parsed[
'socket'] = $proto_opts;
890 if (($pos = strpos($dsn,
'?')) ===
false) {
891 $parsed[
'database'] = $dsn;
894 $parsed[
'database'] = substr($dsn, 0, $pos);
895 $dsn = substr($dsn, $pos + 1);
896 if (strpos($dsn,
'&') !==
false) {
897 $opts = explode(
'&', $dsn);
901 foreach ($opts as $opt) {
902 list(
$key, $value) = explode(
'=', $opt);
903 if (!isset($parsed[
$key])) {
905 $parsed[
$key] = rawurldecode($value);
929 if (!@ini_get(
'safe_mode')) {
930 $dirs = explode(PATH_SEPARATOR, ini_get(
'include_path'));
931 foreach ($dirs as $dir) {
932 if (@is_readable($dir . DIRECTORY_SEPARATOR .
$file)) {
937 $fp = @fopen(
$file,
'r',
true);
938 if (is_resource($fp)) {
972 $level = E_USER_NOTICE, $debuginfo = null)
974 if (is_null(
$code)) {
978 $mode, $level, $debuginfo);
1024 var $connection = 0;
1038 var $database_name =
'';
1045 var $connected_database_name =
'';
1052 var $connected_server_info =
'';
1060 'sequences' =>
false,
1062 'affected_rows' =>
false,
1063 'summary_functions' =>
false,
1064 'order_by_text' =>
false,
1065 'transactions' =>
false,
1066 'savepoints' =>
false,
1067 'current_id' =>
false,
1068 'limit_queries' =>
false,
1071 'sub_selects' =>
false,
1072 'auto_increment' =>
false,
1073 'primary_key' =>
false,
1074 'result_introspection' =>
false,
1075 'prepared_statements' =>
false,
1076 'identifier_quoting' =>
false,
1077 'pattern_escaping' =>
false,
1078 'new_link' =>
false,
1129 'field_case' => CASE_LOWER,
1130 'disable_query' =>
false,
1131 'result_class' =>
'MDB2_Result_%s',
1132 'buffered_result_class' =>
'MDB2_BufferedResult_%s',
1133 'result_wrap_class' =>
false,
1134 'result_buffering' =>
true,
1135 'fetch_class' =>
'stdClass',
1136 'persistent' =>
false,
1138 'debug_handler' =>
'MDB2_defaultDebugOutput',
1139 'debug_expanded_output' =>
false,
1140 'default_text_field_length' => 4096,
1141 'lob_buffer_length' => 8192,
1142 'log_line_break' =>
"\n",
1143 'idxname_format' =>
'%s_idx',
1144 'seqname_format' =>
'%s_seq',
1145 'savepoint_format' =>
'MDB2_SAVEPOINT_%s',
1146 'statement_format' =>
'MDB2_STATEMENT_%1$s_%2$s',
1147 'seqcol_name' =>
'sequence',
1148 'quote_identifier' =>
false,
1149 'use_transactions' =>
true,
1150 'decimal_places' => 2,
1160 'emulate_prepared' =>
false,
1161 'datatype_map' =>
array(),
1162 'datatype_map_callback' =>
array(),
1163 'nativetype_map_callback' =>
array(),
1171 var $string_quoting =
array(
'start' =>
"'",
'end' =>
"'",
'escape' =>
false,
'escape_pattern' =>
false);
1178 var $identifier_quoting =
array(
'start' =>
'"',
'end' =>
'"',
'escape' =>
'"');
1186 array(
'start' =>
'--',
'end' =>
"\n",
'escape' =>
false),
1187 array(
'start' =>
'/*',
'end' =>
'*/',
'escape' =>
false),
1202 var $as_keyword =
' AS ';
1216 var $debug_output =
'';
1223 var $in_transaction =
false;
1230 var $nested_transaction_counter = null;
1237 var $has_transaction_error =
false;
1293 var $destructor_registered =
true;
1304 $db_index = key(
$GLOBALS[
'_MDB2_databases']) + 1;
1305 $GLOBALS[
'_MDB2_databases'][$db_index] = &$this;
1306 $this->db_index = $db_index;
1317 $this->destructor_registered =
false;
1318 $this->__construct();
1329 $this->disconnect(
false);
1344 unset(
$GLOBALS[
'_MDB2_databases'][$this->db_index]);
1345 unset($this->db_index);
1361 $info = get_class($this);
1362 $info.=
': (phptype = '.$this->phptype.
', dbsyntax = '.$this->dbsyntax.
')';
1363 if ($this->connection) {
1364 $info.=
' [connected]';
1417 $error_class = null,
1420 $userinfo =
"[Error message: $userinfo]\n";
1425 if (is_null($mode) && !empty($this->_default_error_mode)) {
1426 $mode = $this->_default_error_mode;
1427 $options = $this->_default_error_options;
1429 if (is_null($userinfo)) {
1430 $userinfo =
$code->getUserinfo();
1436 } elseif (isset($this->connection)) {
1437 if (!empty($this->last_query)) {
1438 $userinfo.=
"[Last executed query: {$this->last_query}]\n";
1440 $native_errno = $native_msg = null;
1441 list(
$code, $native_errno, $native_msg) = $this->errorInfo(
$code);
1442 if (!is_null($native_errno) && $native_errno !==
'') {
1443 $userinfo.=
"[Native code: $native_errno]\n";
1445 if (!is_null($native_msg) && $native_msg !==
'') {
1446 $userinfo.=
"[Native message: ". strip_tags($native_msg) .
"]\n";
1448 if (!is_null($method)) {
1449 $userinfo = $method.
': '.$userinfo;
1455 && isset($this->nested_transaction_counter) && !$this->has_transaction_error) {
1456 $this->has_transaction_error =& $err;
1473 $this->warnings =
array();
1490 return array_reverse($this->warnings);
1517 switch ($fetchmode) {
1519 $this->options[
'fetch_class'] = $object_class;
1522 $this->fetchmode = $fetchmode;
1526 'invalid fetchmode mode', __FUNCTION__);
1547 if (array_key_exists($option, $this->options)) {
1548 $this->options[$option] = $value;
1552 "unknown option $option", __FUNCTION__);
1569 if (array_key_exists($option, $this->options)) {
1570 return $this->options[$option];
1573 "unknown option $option", __FUNCTION__);
1595 if ($this->options[
'debug'] && $this->options[
'debug_handler']) {
1596 if (!$this->options[
'debug_expanded_output']) {
1597 if (!empty($context[
'when']) && $context[
'when'] !==
'pre') {
1600 $context = empty($context[
'is_manip']) ? false : $context[
'is_manip'];
1602 return call_user_func_array($this->options[
'debug_handler'],
array(&$this, $scope,
$message, $context));
1619 return $this->debug_output;
1638 if ($escape_wildcards) {
1642 $text = str_replace($this->string_quoting[
'end'], $this->string_quoting[
'escape'] . $this->string_quoting[
'end'],
$text);
1665 if ($this->string_quoting[
'escape_pattern']) {
1666 $text = str_replace($this->string_quoting[
'escape_pattern'], $this->string_quoting[
'escape_pattern'] . $this->string_quoting[
'escape_pattern'],
$text);
1667 foreach ($this->wildcards as $wildcard) {
1668 $text = str_replace($wildcard, $this->string_quoting[
'escape_pattern'] . $wildcard,
$text);
1713 if ($check_option && !$this->options[
'quote_identifier']) {
1716 $str = str_replace($this->identifier_quoting[
'end'], $this->identifier_quoting[
'escape'] . $this->identifier_quoting[
'end'], $str);
1717 return $this->identifier_quoting[
'start'] . $str . $this->identifier_quoting[
'end'];
1730 return $this->as_keyword;
1750 return $this->connection;
1771 if ($value ===
'') {
1778 if (is_string($value)) {
1786 $tmp_row[preg_replace(
'/^(?:.*\.)?([^.]+)$/',
'\\1',
$key)] = $value;
1792 if ($value ===
'') {
1794 } elseif (is_string($value)) {
1802 if (is_string($value)) {
1803 $value = rtrim($value);
1805 $tmp_row[preg_replace(
'/^(?:.*\.)?([^.]+)$/',
'\\1',
$key)] = $value;
1812 if ($value ===
'') {
1815 $tmp_row[preg_replace(
'/^(?:.*\.)?([^.]+)$/',
'\\1',
$key)] = $value;
1822 if ($value ===
'') {
1824 } elseif (is_string($value)) {
1825 $value = rtrim($value);
1827 $tmp_row[preg_replace(
'/^(?:.*\.)?([^.]+)$/',
'\\1',
$key)] = $value;
1854 $property = strtolower(
$module);
1857 if (!isset($this->{$property})) {
1859 if ($phptype_specific !==
false) {
1861 $class_name =
'MDB2_Driver_'.$module.
'_'.$this->phptype;
1862 $file_name = str_replace(
'_', DIRECTORY_SEPARATOR, $class_name).
'.php';
1864 if ($phptype_specific ===
false 1868 $class_name =
'MDB2_'.$module;
1869 $file_name = str_replace(
'_', DIRECTORY_SEPARATOR, $class_name).
'.php';
1879 if (method_exists($class_name,
'getClassName')) {
1880 $class_name_new = call_user_func(
array($class_name,
'getClassName'), $this->db_index);
1881 if ($class_name != $class_name_new) {
1882 $class_name = $class_name_new;
1893 "unable to load module '$module' into property '$property'", __FUNCTION__);
1896 $this->{$property} =
new $class_name($this->db_index);
1897 $this->modules[
$module] =& $this->{$property};
1902 $this->loaded_version_modules[] = $property;
1906 return $this->{$property};
1923 if (preg_match(
'/^([a-z]+)([A-Z])(.*)$/', $method, $match)
1924 && isset($this->options[
'modules'][$match[1]])
1926 $module = $this->options[
'modules'][$match[1]];
1927 $method = strtolower($match[2]).$match[3];
1928 if (!isset($this->modules[
$module]) || !is_object($this->modules[$module])) {
1929 $result =& $this->loadModule($module);
1935 foreach ($this->modules as
$key => $foo) {
1936 if (is_object($this->modules[
$key])
1937 && method_exists($this->modules[$key], $method)
1947 trigger_error(sprintf(
'Call to undefined function: %s::%s().', get_class($this), $method), E_USER_ERROR);
1963 $this->debug(
'Starting transaction', __FUNCTION__,
array(
'is_manip' =>
true,
'savepoint' => $savepoint));
1965 'transactions are not supported', __FUNCTION__);
1984 $this->debug(
'Committing transaction/savepoint', __FUNCTION__,
array(
'is_manip' =>
true,
'savepoint' => $savepoint));
1986 'commiting transactions is not supported', __FUNCTION__);
2005 $this->debug(
'Rolling back transaction/savepoint', __FUNCTION__,
array(
'is_manip' =>
true,
'savepoint' => $savepoint));
2007 'rolling back transactions is not supported', __FUNCTION__);
2026 if (!$ignore_nested && isset($this->nested_transaction_counter)) {
2027 return $this->nested_transaction_counter;
2029 return $this->in_transaction;
2053 $this->debug(
'Setting transaction isolation level', __FUNCTION__,
array(
'is_manip' =>
true));
2055 'isolation level setting is not supported', __FUNCTION__);
2076 if ($this->in_transaction) {
2077 ++$this->nested_transaction_counter;
2078 $savepoint = sprintf($this->options[
'savepoint_format'], $this->nested_transaction_counter);
2079 if ($this->supports(
'savepoints') && $savepoint) {
2080 return $this->beginTransaction($savepoint);
2084 $this->has_transaction_error =
false;
2085 $result = $this->beginTransaction();
2086 $this->nested_transaction_counter = 1;
2112 if ($this->nested_transaction_counter > 1) {
2113 $savepoint = sprintf($this->options[
'savepoint_format'], $this->nested_transaction_counter);
2114 if ($this->supports(
'savepoints') && $savepoint) {
2115 if ($force_rollback || $this->has_transaction_error) {
2116 $result = $this->rollback($savepoint);
2119 $this->has_transaction_error =
false;
2122 $result = $this->commit($savepoint);
2127 --$this->nested_transaction_counter;
2131 $this->nested_transaction_counter = null;
2135 if ($this->in_transaction) {
2136 if ($force_rollback || $this->has_transaction_error) {
2145 $this->has_transaction_error =
false;
2170 $error = $this->has_transaction_error ? $this->has_transaction_error :
true;
2174 $this->has_transaction_error =
$error;
2175 if (!$immediately) {
2178 return $this->rollback();
2199 return $this->has_transaction_error;
2213 'method not implemented', __FUNCTION__);
2230 'method not implemented', __FUNCTION__);
2249 $this->connection = 0;
2250 $this->connected_dsn =
array();
2251 $this->connected_database_name =
'';
2252 $this->opened_persistent = null;
2253 $this->connected_server_info =
'';
2254 $this->in_transaction = null;
2255 $this->nested_transaction_counter = null;
2273 $previous_database_name = (isset($this->database_name)) ? $this->database_name :
'';
2274 $this->database_name =
$name;
2275 $this->disconnect(
false);
2276 return $previous_database_name;
2291 return $this->database_name;
2308 $dsn_default =
$GLOBALS[
'_MDB2_dsninfo_default'];
2310 if (array_key_exists(
'database', $dsn)) {
2311 $this->database_name = $dsn[
'database'];
2312 unset($dsn[
'database']);
2314 $this->dsn = array_merge($dsn_default, $dsn);
2315 return $this->disconnect(
false);
2333 $dsn = array_merge(
$GLOBALS[
'_MDB2_dsninfo_default'], $this->dsn);
2334 $dsn[
'phptype'] = $this->phptype;
2335 $dsn[
'database'] = $this->database_name;
2337 $dsn[
'password'] = $hidepw;
2342 $dsn = $dsn[
'phptype'].
2343 ($dsn[
'dbsyntax'] ? (
'('.$dsn[
'dbsyntax'].
')') :
'').
2344 '://'.$dsn[
'username'].
':'.
2345 $dsn[
'password'].
'@'.$dsn[
'hostspec'].
2346 ($dsn[
'port'] ? (
':'.$dsn[
'port']) :
'').
2347 '/'.$dsn[
'database'];
2373 $offset = $this->offset;
2374 $limit = $this->limit;
2375 $this->offset = $this->limit = 0;
2376 $query = $this->_modifyQuery(
$query, $is_manip, $limit, $offset);
2378 $connection = $this->getConnection();
2383 $result =& $this->_doQuery(
$query, $is_manip, $connection,
false);
2389 $affected_rows = $this->_affectedRows($connection,
$result);
2390 return $affected_rows;
2392 $result =& $this->_wrapResult(
$result, $types,
true,
false, $limit, $offset);
2430 function &
_doQuery(
$query, $is_manip =
false, $connection = null, $database_name = null)
2432 $this->last_query =
$query;
2433 $result = $this->debug(
$query,
'query',
array(
'is_manip' => $is_manip,
'when' =>
'pre'));
2441 'method not implemented', __FUNCTION__);
2461 'method not implemented', __FUNCTION__);
2478 $offset = $this->offset;
2479 $limit = $this->limit;
2480 $this->offset = $this->limit = 0;
2481 $query = $this->_modifyQuery(
$query,
true, $limit, $offset);
2483 $connection = $this->getConnection();
2488 $result =& $this->_doQuery(
$query,
true, $connection, $this->database_name);
2493 $affectedRows = $this->_affectedRows($connection,
$result);
2494 return $affectedRows;
2513 function &
query(
$query, $types = null, $result_class =
true, $result_wrap_class =
false)
2515 $offset = $this->offset;
2516 $limit = $this->limit;
2517 $this->offset = $this->limit = 0;
2518 $query = $this->_modifyQuery(
$query,
false, $limit, $offset);
2520 $connection = $this->getConnection();
2525 $result =& $this->_doQuery(
$query,
false, $connection, $this->database_name);
2530 $result =& $this->_wrapResult(
$result, $types, $result_class, $result_wrap_class, $limit, $offset);
2553 $result_wrap_class =
false, $limit = null, $offset = null)
2555 if ($types ===
true) {
2556 if ($this->supports(
'result_introspection')) {
2557 $this->loadModule(
'Reverse', null,
true);
2558 $tableInfo = $this->reverse->tableInfo(
$result);
2563 foreach ($tableInfo as $field) {
2564 $types[] = $field[
'mdb2type'];
2571 if ($result_class ===
true) {
2572 $result_class = $this->options[
'result_buffering']
2573 ? $this->options[
'buffered_result_class'] : $this->options[
'result_class'];
2576 if ($result_class) {
2577 $class_name = sprintf($result_class, $this->phptype);
2580 'result class does not exist '.$class_name, __FUNCTION__);
2586 'result class is not extended from MDB2_Result_Common', __FUNCTION__);
2589 if (!empty($types)) {
2590 $err =
$result->setResultTypes($types);
2597 if ($result_wrap_class ===
true) {
2598 $result_wrap_class = $this->options[
'result_wrap_class'];
2600 if ($result_wrap_class) {
2603 'result wrap class does not exist '.$result_wrap_class, __FUNCTION__);
2626 'method not implemented', __FUNCTION__);
2644 if (!$this->supports(
'limit_queries')) {
2646 'limit is not supported by this driver', __FUNCTION__);
2648 $limit = (int)$limit;
2651 'it was not specified a valid selected range row limit', __FUNCTION__);
2653 $this->limit = $limit;
2654 if (!is_null($offset)) {
2655 $offset = (int)$offset;
2658 'it was not specified a valid first selected range row', __FUNCTION__);
2660 $this->offset = $offset;
2682 if ($this->supports(
'sub_selects') ===
true) {
2686 if (!$this->supports(
'sub_selects')) {
2688 'method not implemented', __FUNCTION__);
2695 if (!is_array($col) || count($col) == 0) {
2699 $this->loadModule(
'Datatype', null,
true);
2700 return $this->datatype->implodeArray($col,
$type);
2702 return implode(
', ', $col);
2773 if (!$this->supports(
'replace')) {
2775 'replace query is not supported', __FUNCTION__);
2777 $count = count($fields);
2778 $condition = $values =
array();
2779 for ($colnum = 0, reset($fields); $colnum < $count; next($fields), $colnum++) {
2780 $name = key($fields);
2781 if (isset($fields[
$name][
'null']) && $fields[$name][
'null']) {
2784 $type = isset($fields[$name][
'type']) ? $fields[
$name][
'type'] : null;
2785 $value = $this->quote($fields[$name][
'value'],
$type);
2787 $values[
$name] = $value;
2788 if (isset($fields[$name][
'key']) && $fields[$name][
'key']) {
2789 if ($value ===
'NULL') {
2791 'key value '.$name.
' may not be NULL', __FUNCTION__);
2793 $condition[] = $name .
'=' . $value;
2796 if (empty($condition)) {
2798 'not specified which fields are keys', __FUNCTION__);
2802 $in_transaction = $this->in_transaction;
2807 $connection = $this->getConnection();
2812 $condition =
' WHERE '.implode(
' AND ', $condition);
2813 $query =
"DELETE FROM $table$condition";
2816 $affected_rows = $this->_affectedRows($connection,
$result);
2817 $insert = implode(
', ', array_keys($values));
2818 $values = implode(
', ', $values);
2819 $query =
"INSERT INTO $table ($insert) VALUES ($values)";
2822 $affected_rows += $this->_affectedRows($connection,
$result);;
2826 if (!$in_transaction) {
2838 return $affected_rows;
2869 $offset = $this->offset;
2870 $limit = $this->limit;
2871 $this->offset = $this->limit = 0;
2872 $result = $this->debug(
$query, __FUNCTION__,
array(
'is_manip' => $is_manip,
'when' =>
'pre'));
2879 $placeholder_type_guess = $placeholder_type = null;
2882 $positions =
array();
2884 $ignores = $this->sql_comments;
2885 $ignores[] = $this->string_quoting;
2886 $ignores[] = $this->identifier_quoting;
2887 while ($position < strlen(
$query)) {
2888 $q_position = strpos(
$query, $question, $position);
2889 $c_position = strpos(
$query, $colon, $position);
2890 if ($q_position && $c_position) {
2891 $p_position = min($q_position, $c_position);
2892 } elseif ($q_position) {
2893 $p_position = $q_position;
2894 } elseif ($c_position) {
2895 $p_position = $c_position;
2899 if (is_null($placeholder_type)) {
2900 $placeholder_type_guess =
$query[$p_position];
2903 $new_pos = $this->_skipDelimitedStrings(
$query, $position, $p_position);
2907 if ($new_pos != $position) {
2908 $position = $new_pos;
2912 if (
$query[$position] == $placeholder_type_guess) {
2913 if (is_null($placeholder_type)) {
2914 $placeholder_type =
$query[$p_position];
2915 $question = $colon = $placeholder_type;
2916 if (!empty($types) && is_array($types)) {
2917 if ($placeholder_type ==
':') {
2918 if (is_int(key($types))) {
2919 $types_tmp = $types;
2924 $types = array_values($types);
2928 if ($placeholder_type ==
':') {
2929 $parameter = preg_replace(
'/^.{'.($position+1).
'}([a-z0-9_]+).*$/si',
'\\1',
$query);
2930 if ($parameter ===
'') {
2932 'named parameter with an empty name', __FUNCTION__);
2935 $positions[$p_position] = $parameter;
2936 $query = substr_replace(
$query,
'?', $position, strlen($parameter)+1);
2938 if (isset($count) && isset($types_tmp[++$count])) {
2939 $types[$parameter] = $types_tmp[$count];
2942 $positions[$p_position] = count($positions);
2944 $position = $p_position + 1;
2946 $position = $p_position;
2949 $class_name =
'MDB2_Statement_'.$this->phptype;
2951 $obj =
new $class_name($this, $statement, $positions,
$query, $types, $result_types, $is_manip, $limit, $offset);
2952 $this->debug(
$query, __FUNCTION__,
array(
'is_manip' => $is_manip,
'when' =>
'post',
'result' => $obj));
2976 $ignores = $this->sql_comments;
2977 $ignores[] = $this->string_quoting;
2978 $ignores[] = $this->identifier_quoting;
2980 foreach ($ignores as
$ignore) {
2981 if (!empty($ignore[
'start'])) {
2982 if (is_int($start_quote = strpos(
$query, $ignore[
'start'], $position)) && $start_quote < $p_position) {
2983 $end_quote = $start_quote;
2985 if (!is_int($end_quote = strpos(
$query, $ignore[
'end'], $end_quote + 1))) {
2986 if ($ignore[
'end'] ===
"\n") {
2987 $end_quote = strlen(
$query) - 1;
2990 'query with an unterminated text string specified', __FUNCTION__);
2994 }
while ($ignore[
'escape'] &&
$query[($end_quote - 1)] == $ignore[
'escape']);
2995 $position = $end_quote + 1;
3020 function quote($value,
$type = null, $quote =
true, $escape_wildcards =
false)
3022 $result = $this->loadModule(
'Datatype', null,
true);
3027 return $this->datatype->quote($value,
$type, $quote, $escape_wildcards);
3048 $result = $this->loadModule(
'Datatype', null,
true);
3052 return $this->datatype->getDeclaration(
$type,
$name, $field);
3070 $result = $this->loadModule(
'Datatype', null,
true);
3074 return $this->datatype->compareDefinition(
$current, $previous);
3094 if (array_key_exists($feature, $this->supported)) {
3095 return $this->supported[$feature];
3098 "unknown support feature $feature", __FUNCTION__);
3115 return sprintf($this->options[
'seqname_format'],
3116 preg_replace(
'/[^a-z0-9_\$.]/i',
'_', $sqn));
3133 return sprintf($this->options[
'idxname_format'],
3134 preg_replace(
'/[^a-z0-9_\$]/i',
'_', $idx));
3153 'method not implemented', __FUNCTION__);
3173 'method not implemented', __FUNCTION__);
3190 $this->warnings[] =
'database does not support getting current 3191 sequence value, the sequence value was incremented';
3192 return $this->nextID($seq_name);
3221 $one =
$result->fetchOne($colnum);
3282 $col =
$result->fetchCol($colnum);
3315 $rekey =
false, $force_array =
false, $group =
false)
3322 $all =
$result->fetchAll($fetchmode, $rekey, $force_array, $group);
3346 require_once(
'./Services/Database/interfaces/interface.ilDBStatement.php');
3364 var $offset_count = 0;
3378 $this->offset = $offset;
3379 $this->limit = max(0, $limit - 1);
3384 return $this->fetchRow($fetch_mode);
3405 $this->__construct($db, $result, $limit, $offset);
3434 $load = $this->db->loadModule(
'Datatype', null,
true);
3438 $types = $this->db->datatype->checkResultTypes($types);
3442 $this->types = $types;
3460 $target_rownum = $rownum - 1;
3461 if ($this->rownum > $target_rownum) {
3463 'seeking to previous rows not implemented', __FUNCTION__);
3465 while ($this->rownum < $target_rownum) {
3487 'method not implemented', __FUNCTION__);
3507 $row = $this->fetchRow($fetchmode, $rownum);
3511 if (!array_key_exists($colnum,
$row)) {
3513 'column is not defined in the result set: '.$colnum, __FUNCTION__);
3515 return $row[$colnum];
3534 $row = $this->fetchRow($fetchmode);
3535 if (is_array(
$row)) {
3536 if (!array_key_exists($colnum,
$row)) {
3538 'column is not defined in the result set: '.$colnum, __FUNCTION__);
3542 }
while (is_array(
$row = $this->fetchRow($fetchmode)));
3577 $force_array =
false, $group =
false)
3580 $row = $this->fetchRow($fetchmode);
3587 $shift_array = $rekey ? false : null;
3588 if (!is_null($shift_array)) {
3589 if (is_object(
$row)) {
3590 $colnum = count(get_object_vars(
$row));
3592 $colnum = count(
$row);
3596 'rekey feature requires atleast 2 column', __FUNCTION__);
3598 $shift_array = (!$force_array && $colnum == 2);
3603 if (is_object(
$row)) {
3604 $arr = get_object_vars(
$row);
3623 }
while ((
$row = $this->fetchRow($fetchmode)));
3627 $all[
$key][] = $val;
3629 }
while ((
$row = $this->fetchRow($fetchmode)));
3633 }
while ((
$row = $this->fetchRow($fetchmode)));
3649 return $this->rownum + 1;
3665 'method not implemented', __FUNCTION__);
3681 'method not implemented', __FUNCTION__);
3702 if (!isset($this->column_names)) {
3703 $result = $this->_getColumnNames();
3707 $this->column_names =
$result;
3710 return array_flip($this->column_names);
3712 return $this->column_names;
3731 'method not implemented', __FUNCTION__);
3748 'method not implemented', __FUNCTION__);
3783 $column_names = $this->getColumnNames();
3785 if ($this->db->options[
'field_case'] == CASE_LOWER) {
3793 $this->values[
$column] =& $value;
3794 if (!is_null(
$type)) {
3816 if (array_key_exists(
$column, $this->values)) {
3817 $this->values[
$column] = $value;
3835 $this->result =
false;
3846 $res = $this->result->execute($a_data);
3848 throw new ilDatabaseException(
"There was an MDB2 error executing the prepared query: ".$this->result->getMessage());
3890 $this->__construct(
$row);
3926 function __construct(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip =
false, $limit = null, $offset = null)
3929 $this->statement =& $statement;
3930 $this->positions = $positions;
3932 $this->types = (
array)$types;
3933 $this->result_types = (
array)$result_types;
3934 $this->limit = $limit;
3935 $this->is_manip = $is_manip;
3936 $this->offset = $offset;
3945 function MDB2_Statement_Common(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip =
false, $limit = null, $offset = null)
3947 $this->__construct($db, $statement, $positions, $query, $types, $result_types, $is_manip, $limit, $offset);
3968 if (!is_numeric($parameter)) {
3969 $parameter = preg_replace(
'/^:(.*)$/',
'\\1', $parameter);
3971 if (!in_array($parameter, $this->positions)) {
3973 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
3975 $this->values[$parameter] = $value;
3976 if (!is_null(
$type)) {
3977 $this->types[$parameter] =
$type;
4000 $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
4001 $parameters = array_keys($values);
4002 foreach ($parameters as
$key => $parameter) {
4003 $err = $this->bindValue($parameter, $values[$parameter], $types[
$key]);
4029 if (!is_numeric($parameter)) {
4030 $parameter = preg_replace(
'/^:(.*)$/',
'\\1', $parameter);
4032 if (!in_array($parameter, $this->positions)) {
4034 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
4036 $this->values[$parameter] =& $value;
4037 if (!is_null(
$type)) {
4038 $this->types[$parameter] =
$type;
4061 $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
4062 $parameters = array_keys($values);
4063 foreach ($parameters as
$key => $parameter) {
4064 $err = $this->bindParam($parameter, $values[$parameter], $types[
$key]);
4088 function &
execute($values = null, $result_class =
true, $result_wrap_class =
false)
4090 if (is_null($this->positions)) {
4091 return $this->db->raiseError(
MDB2_ERROR, null, null,
4092 'Prepared statement has already been freed', __FUNCTION__);
4095 $values = (
array)$values;
4096 if (!empty($values)) {
4097 $err = $this->bindValueArray($values);
4099 return $this->db->raiseError(
MDB2_ERROR, null, null,
4100 'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
4103 $result =& $this->_execute($result_class, $result_wrap_class);
4120 function &
_execute($result_class =
true, $result_wrap_class =
false)
4125 foreach ($this->positions as $current_position => $parameter) {
4126 if (!array_key_exists($parameter, $this->values)) {
4128 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
4130 $value = $this->values[$parameter];
4131 $query.= substr($this->query, $last_position, $current_position - $last_position);
4132 if (!isset($value)) {
4133 $value_quoted =
'NULL';
4135 $type = !empty($this->types[$parameter]) ? $this->types[$parameter] : null;
4136 $value_quoted = $this->db->quote($value,
$type);
4138 return $value_quoted;
4141 $query.= $value_quoted;
4142 $last_position = $current_position + 1;
4144 $query.= substr($this->query, $last_position);
4146 $this->db->offset = $this->offset;
4147 $this->db->limit = $this->limit;
4148 if ($this->is_manip) {
4149 $result = $this->db->exec($query);
4151 $result =& $this->db->query($query, $this->result_types, $result_class, $result_wrap_class);
4168 if (is_null($this->positions)) {
4169 return $this->db->raiseError(
MDB2_ERROR, null, null,
4170 'Prepared statement has already been freed', __FUNCTION__);
4173 $this->statement = null;
4174 $this->positions = null;
4175 $this->query = null;
4176 $this->types = null;
4177 $this->result_types = null;
4178 $this->limit = null;
4179 $this->is_manip = null;
4180 $this->offset = null;
4181 $this->values = null;
4220 $this->db_index = $db_index;
4231 $this->__construct($db_index);
4246 if (isset(
$GLOBALS[
'_MDB2_databases'][$this->db_index])) {
4250 'could not find MDB2 instance');
4271 reset(
$GLOBALS[
'_MDB2_databases']);
4272 while (next(
$GLOBALS[
'_MDB2_databases'])) {
4274 if (
$GLOBALS[
'_MDB2_databases'][
$key]->opened_persistent
4303 $db->debug_output.= $scope.
'('.$db->db_index.
'): ';
4304 $db->debug_output.=
$message.$db->getOption(
'log_line_break');
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
fetch($fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
getOption($option)
Returns the value of an option.
const MDB2_OK(!class_exists('PEAR'))
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these...
& fetchRow($fetchmode=MDB2_FETCHMODE_DEFAULT, $rownum=null)
Fetch and return a row of data.
nextID($seq_name, $ondemand=true)
Returns the next free id of a sequence.
bindColumn($column, &$value, $type=null)
Set bind variable to a column.
const MDB2_ERROR_CANNOT_REPLACE
getResource()
return the resource associated with the result object
MDB2_Statement_Common(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip=false, $limit=null, $offset=null)
PHP 4 Constructor.
beginTransaction($savepoint=null)
Start a transaction or set a savepoint.
_affectedRows($connection, $result=null)
Returns the number of rows affected.
getIndexName($idx)
adds index name formatting to a index name
loadFile($file)
load a file (like 'Date')
MDB2_Driver_Common()
PHP 4 Constructor.
isResult($value)
Tell whether a value is a MDB2 result.
setTransactionIsolation($isolation, $options=array())
Set the transacton isolation level.
const MDB2_FETCHMODE_DEFAULT
This is a special constant that tells MDB2 the user hasn't specified any particular get mode...
isError($data, $code=null)
Tell whether a value is a MDB2 error.
const MDB2_ERROR_UNSUPPORTED
supports($feature)
Tell whether a DB implementation or its backend extension supports a given feature.
const MDB2_ERROR_NOSUCHDB
bindValue($parameter, $value, $type=null)
Set the value of a parameter of a prepared query.
Several methods to convert the MDB2 native timestamp format (ISO based) to and from data structures t...
setLimit($limit, $offset=null)
set the range of the next query
const MDB2_ERROR_CANNOT_DROP
$GLOBALS['_MDB2_databases']
These are global variables that are used to track the various class instances.
__construct($code=MDB2_ERROR, $mode=PEAR_ERROR_RETURN, $level=E_USER_NOTICE, $debuginfo=null)
MDB2_Error constructor.
const MDB2_PORTABILITY_EMPTY_TO_NULL
Portability: convert empty values to null strings in data output by query*() and fetch*().
const MDB2_ERROR_NOT_CAPABLE
const MDB2_ERROR_CANNOT_ALTER
const MDB2_ERROR_CANNOT_DELETE
__toString()
String conversation.
bindValueArray($values, $types=null)
Set the values of multiple a parameter of a prepared query in bulk.
disconnect($force=true)
Log out and disconnect from the database.
const MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES
Portability: removes database/table qualifiers from associative indexes.
fetchAll($fetchmode=MDB2_FETCHMODE_DEFAULT, $rekey=false, $force_array=false, $group=false)
Fetch and return all rows from the current row pointer position.
free()
Free the internal references so that the instance can be destroyed.
bindParamArray(&$values, $types=null)
Bind the variables of multiple a parameter of a prepared query in bulk.
connect()
Connect to the database.
fetchCol($colnum=0)
Fetch and return a column from the current row pointer position.
& exec($query)
Execute a manipulation query to the database and return the number of affected rows.
apiVersion()
Return the MDB2 API version.
const MDB2_FETCHMODE_FLIPPED
For multi-dimensional results: normally the first level of arrays is the row number, and the second level indexed by column number or name.
numCols()
Count the number of columns returned by the DBMS in a query result.
quoteIdentifier($str, $check_option=false)
Quote a string so it can be safely used as a table or column name.
Class ilDatabaseException.
beginNestedTransaction()
Start a nested transaction.
setDatabase($name)
Select a different database.
numRows()
Returns the number of rows in a result object.
_assignBindColumns($row)
Bind a variable to a value in the result row.
compareDefinition($current, $previous)
Obtain an array of changes that may need to applied.
& _doQuery($query, $is_manip=false, $connection=null, $database_name=null)
Execute a query.
rowCount()
Returns the actual row number that was last fetched (count from 0)
const MDB2_ERROR_CONSTRAINT
commit($savepoint=null)
Commit the database changes done during a transaction that is in progress or release a savepoint...
__construct($db, $result, $limit=0, $offset=0)
Constructor.
getSequenceName($sqn)
adds sequence name formatting to a sequence name
_getColumnNames()
Retrieve the names of columns returned by the DBMS in a query result.
free()
Release resources allocated for the specified prepared query.
getDebugOutput()
output debug info
if($modEnd===false) $module
const MDB2_ERROR_INVALID_DATE
MDB2_closeOpenTransactions()
Close any open transactions form persistent connections.
escape($text, $escape_wildcards=false)
Quotes a string so it can be safely used in a query.
& prepare($query, $types=null, $result_types=null, $lobs=array())
Prepares a query for multiple execution with execute().
_modifyQuery($query, $is_manip, $limit, $offset)
Changes a query string for various DBMS specific reasons.
const MDB2_ERROR_INVALID_DSN
MDB2_Result_Common($db, $result, $limit=0, $offset=0)
PHP 4 Constructor.
const MDB2_ERROR_NOSUCHFIELD
& query($query, $types=null, $result_class=true, $result_wrap_class=false)
Send a query to the database and return any results.
const MDB2_FETCHMODE_OBJECT
Column data as object properties.
debug($message, $scope='', $context=array())
set a debug message
& _wrapResult($result, $types=array(), $result_class=true, $result_wrap_class=false, $limit=null, $offset=null)
wrap a result set into the correct class
_skipDelimitedStrings($query, $position, $p_position)
Utility method, used by prepare() to avoid replacing placeholders within delimited strings...
MDB2_Module_Common($db_index)
PHP 4 Constructor.
catch(Exception $e) $message
const MDB2_FETCHMODE_ORDERED
Column data indexed by numbers, ordered from 0 and up.
__construct(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip=false, $limit=null, $offset=null)
Constructor.
const MDB2_PREPARE_MANIP
These are just helper constants to more verbosely express parameters to prepare() ...
& standaloneQuery($query, $types=null, $is_manip=false)
execute a query as database administrator
foreach($_POST as $key=> $value) $res
failNestedTransaction($error=null, $immediately=false)
Force setting nested transaction to failed.
replace($table, $fields)
Execute a SQL REPLACE query.
& connect($dsn, $options=false)
Create a new MDB2 connection object and connect to the specified database.
& factory($dsn, $options=false)
Create a new MDB2 object for the specified database type.
const MDB2_ERROR_NEED_MORE_DATA
getNestedTransactionError()
The first error that occured since the transaction start.
const MDB2_PORTABILITY_RTRIM
Portability: right trim the data output by query*() and fetch*().
isResultCommon($value)
Tell whether a value is a MDB2 result implementing the common interface.
setOption($option, $value)
set the option for the db class
setResultTypes($types)
Define the list of types to be associated with the columns of a given result set. ...
isStatement($value)
Tell whether a value is a MDB2 statement interface.
const MDB2_PORTABILITY_ALL
Portability: turn on all portability features.
loadClass($class_name, $debug)
Loads a PEAR class.
const PEAR_ERROR_RETURN
#+ ERROR constants
const MDB2_ERROR_NOT_FOUND
completeNestedTransaction($force_rollback=false)
Finish a nested transaction by rolling back if an error occured or committing otherwise.
classExists($classname)
Checks if a class exists without triggering __autoload.
lastInsertID($table=null, $field=null)
Returns the autoincrement ID if supported or $id or fetches the current ID in a sequence called: $tab...
seek($rownum=0)
Seek to a specific row in a result set.
const MDB2_ERROR_NOT_LOCKED
const MDB2_ERROR_CONNECT_FAILED
& _execute($result_class=true, $result_wrap_class=false)
Execute a prepared query statement helper method.
inTransaction($ignore_nested=false)
If a transaction is currently open.
const MDB2_ERROR_CONSTRAINT_NOT_NULL
_fixResultArrayValues(&$row, $mode)
Do all necessary conversions on result arrays to fix DBMS quirks.
queryAll($query, $types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT, $rekey=false, $force_array=false, $group=false)
Execute the specified query, fetch all the rows of the result set into a two dimensional array and th...
currID($seq_name)
Returns the current id of a sequence.
Create styles array
The data for the language used.
const MDB2_ERROR_CANNOT_CREATE
getDatabase()
Get the current database.
isConnection($value)
Tell whether a value is a MDB2 connection.
const MDB2_ERROR_MISMATCH
& singleton($dsn=null, $options=false)
Returns a MDB2 connection with the requested DSN.
__call($method, $params)
Calls a module method using the __call magic method.
const MDB2_ERROR_VALUE_COUNT_ON_ROW
nextResult()
Move the internal result pointer to the next available result.
bindParam($parameter, &$value, $type=null)
Bind a variable to a parameter of a prepared query.
__construct(&$row)
constructor
fetchOne($colnum=0, $rownum=null)
fetch single column from the next row from a result set
escapePattern($text)
Quotes pattern (% and _) characters in a string)
& execute($values=null, $result_class=true, $result_wrap_class=false)
Execute a prepared query statement.
const MDB2_ERROR_INVALID_NUMBER
const MDB2_ERROR_EXTENSION_NOT_FOUND
getConnection()
Returns a native connection.
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is used to communicate an error and invoke error callbacks etc.
& raiseError($code=null, $mode=null, $options=null, $userinfo=null)
This method is used to communicate an error and invoke error callbacks etc.
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is a wrapper that returns an instance of the configured error class with this object's de...
__construct($db_index)
Constructor.
quote($value, $type=null, $quote=true, $escape_wildcards=false)
Convert a text value into a DBMS specific format that is suitable to compose query statements...
queryRow($query, $types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT)
Execute the specified query, fetch the values from the first row of the result set into an array and ...
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
queryOne($query, $type=null, $colnum=0)
Execute the specified query, fetch the value from the first column of the first row of the result set...
const MDB2_ERROR_NODBSELECTED
const MDB2_ERROR_DEADLOCK
const MDB2_ERROR_TRUNCATED
getDSN($type='string', $hidepw=false)
return the DSN as a string
setOptions(&$db, $options)
set option array in an exiting database object
queryCol($query, $type=null, $colnum=0)
Execute the specified query, fetch the value from the first column of each row of the result set into...
rollback($savepoint=null)
Cancel any database changes done during a transaction or since a specific savepoint that is in progre...
errorMessage($value=null)
Return a textual error message for a MDB2 error code.
MDB2_defaultDebugOutput(&$db, $scope, $message, $context=array())
default debug output handler
const MDB2_ERROR_LOADMODULE
fileExists($file)
Checks if a file exists in the include path.
const MDB2_ERROR_ACCESS_VIOLATION
setCharset($charset, $connection=null)
Set the charset on the current connection.
resetWarnings()
reset the warning array
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
if(empty($password)) $table
MDB2_Row(&$row)
PHP 4 Constructor.
getServerVersion($native=false)
return version information about the server
errorInfo($error=null)
This method is used to collect information about an error.
while(false !==($line=fgets($in))) if(! $columns) $ignore
getColumnNames($flip=false)
Retrieve the names of columns returned by the DBMS in a query result or from the cache.
free()
Free the internal resources associated with result.
& loadModule($module, $property=null, $phptype_specific=null)
loads a module
getDeclaration($type, $name, $field)
Obtain DBMS specific SQL code portion needed to declare of the given type.
const MDB2_ERROR_ALREADY_EXISTS
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
__construct()
Constructor.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
isError($data, $code=null)
Tell whether a value is a PEAR error.
getAsKeyword()
Gets the string to alias column.
subSelect($query, $type=false)
simple subselect emulation: leaves the query untouched for all RDBMS that support subselects ...
setFetchMode($fetchmode, $object_class='stdClass')
Sets which fetch mode should be used by default on queries on this connection.
getWarnings()
Get all warnings in reverse order.
const MDB2_ERROR_NOSUCHTABLE