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'];
389 $debug = (!empty(
$options[
'debug']));
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);
491 $keys = array_keys(
$GLOBALS[
'_MDB2_databases']);
492 for ($i=0, $j=count($keys); $i<$j; ++$i) {
493 if (isset(
$GLOBALS[
'_MDB2_databases'][$keys[$i]])) {
494 $tmp_dsn =
$GLOBALS[
'_MDB2_databases'][$keys[$i]]->getDSN(
'array');
495 if (count(array_diff_assoc($tmp_dsn, $dsninfo)) == 0) {
497 return $GLOBALS[
'_MDB2_databases'][$keys[$i]];
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]';
1412 function &
raiseError(
$code = null, $mode = null, $options = null, $userinfo = null, $method = null)
1414 $userinfo =
"[Error message: $userinfo]\n";
1419 if (is_null($mode) && !empty($this->_default_error_mode)) {
1420 $mode = $this->_default_error_mode;
1421 $options = $this->_default_error_options;
1423 if (is_null($userinfo)) {
1424 $userinfo =
$code->getUserinfo();
1430 } elseif (isset($this->connection)) {
1431 if (!empty($this->last_query)) {
1432 $userinfo.=
"[Last executed query: {$this->last_query}]\n";
1434 $native_errno = $native_msg = null;
1435 list(
$code, $native_errno, $native_msg) = $this->errorInfo(
$code);
1436 if (!is_null($native_errno) && $native_errno !==
'') {
1437 $userinfo.=
"[Native code: $native_errno]\n";
1439 if (!is_null($native_msg) && $native_msg !==
'') {
1440 $userinfo.=
"[Native message: ". strip_tags($native_msg) .
"]\n";
1442 if (!is_null($method)) {
1443 $userinfo = $method.
': '.$userinfo;
1449 && isset($this->nested_transaction_counter) && !$this->has_transaction_error) {
1450 $this->has_transaction_error =& $err;
1467 $this->warnings =
array();
1484 return array_reverse($this->warnings);
1511 switch ($fetchmode) {
1513 $this->options[
'fetch_class'] = $object_class;
1516 $this->fetchmode = $fetchmode;
1520 'invalid fetchmode mode', __FUNCTION__);
1541 if (array_key_exists($option, $this->options)) {
1542 $this->options[$option] = $value;
1546 "unknown option $option", __FUNCTION__);
1563 if (array_key_exists($option, $this->options)) {
1564 return $this->options[$option];
1567 "unknown option $option", __FUNCTION__);
1589 if ($this->options[
'debug'] && $this->options[
'debug_handler']) {
1590 if (!$this->options[
'debug_expanded_output']) {
1591 if (!empty($context[
'when']) && $context[
'when'] !==
'pre') {
1594 $context = empty($context[
'is_manip']) ? false : $context[
'is_manip'];
1596 return call_user_func_array($this->options[
'debug_handler'],
array(&$this, $scope, $message, $context));
1613 return $this->debug_output;
1632 if ($escape_wildcards) {
1636 $text = str_replace($this->string_quoting[
'end'], $this->string_quoting[
'escape'] . $this->string_quoting[
'end'],
$text);
1659 if ($this->string_quoting[
'escape_pattern']) {
1660 $text = str_replace($this->string_quoting[
'escape_pattern'], $this->string_quoting[
'escape_pattern'] . $this->string_quoting[
'escape_pattern'],
$text);
1661 foreach ($this->wildcards as $wildcard) {
1662 $text = str_replace($wildcard, $this->string_quoting[
'escape_pattern'] . $wildcard,
$text);
1707 if ($check_option && !$this->options[
'quote_identifier']) {
1710 $str = str_replace($this->identifier_quoting[
'end'], $this->identifier_quoting[
'escape'] . $this->identifier_quoting[
'end'], $str);
1711 return $this->identifier_quoting[
'start'] . $str . $this->identifier_quoting[
'end'];
1724 return $this->as_keyword;
1744 return $this->connection;
1764 foreach (
$row as $key => $value) {
1765 if ($value ===
'') {
1771 foreach (
$row as $key => $value) {
1772 if (is_string($value)) {
1773 $row[$key] = rtrim($value);
1779 foreach (
$row as $key => $value) {
1780 $tmp_row[preg_replace(
'/^(?:.*\.)?([^.]+)$/',
'\\1', $key)] = $value;
1785 foreach (
$row as $key => $value) {
1786 if ($value ===
'') {
1788 } elseif (is_string($value)) {
1789 $row[$key] = rtrim($value);
1795 foreach (
$row as $key => $value) {
1796 if (is_string($value)) {
1797 $value = rtrim($value);
1799 $tmp_row[preg_replace(
'/^(?:.*\.)?([^.]+)$/',
'\\1', $key)] = $value;
1805 foreach (
$row as $key => $value) {
1806 if ($value ===
'') {
1809 $tmp_row[preg_replace(
'/^(?:.*\.)?([^.]+)$/',
'\\1', $key)] = $value;
1815 foreach (
$row as $key => $value) {
1816 if ($value ===
'') {
1818 } elseif (is_string($value)) {
1819 $value = rtrim($value);
1821 $tmp_row[preg_replace(
'/^(?:.*\.)?([^.]+)$/',
'\\1', $key)] = $value;
1845 function &
loadModule($module, $property = null, $phptype_specific = null)
1848 $property = strtolower($module);
1851 if (!isset($this->{$property})) {
1853 if ($phptype_specific !==
false) {
1855 $class_name =
'MDB2_Driver_'.$module.
'_'.$this->phptype;
1856 $file_name = str_replace(
'_', DIRECTORY_SEPARATOR, $class_name).
'.php';
1858 if ($phptype_specific ===
false 1862 $class_name =
'MDB2_'.$module;
1863 $file_name = str_replace(
'_', DIRECTORY_SEPARATOR, $class_name).
'.php';
1873 if (method_exists($class_name,
'getClassName')) {
1874 $class_name_new = call_user_func(
array($class_name,
'getClassName'), $this->db_index);
1875 if ($class_name != $class_name_new) {
1876 $class_name = $class_name_new;
1887 "unable to load module '$module' into property '$property'", __FUNCTION__);
1890 $this->{$property} =
new $class_name($this->db_index);
1891 $this->modules[$module] =& $this->{$property};
1896 $this->loaded_version_modules[] = $property;
1900 return $this->{$property};
1917 if (preg_match(
'/^([a-z]+)([A-Z])(.*)$/', $method, $match)
1918 && isset($this->options[
'modules'][$match[1]])
1920 $module = $this->options[
'modules'][$match[1]];
1921 $method = strtolower($match[2]).$match[3];
1922 if (!isset($this->modules[$module]) || !is_object($this->modules[$module])) {
1923 $result =& $this->loadModule($module);
1929 foreach ($this->modules as $key => $foo) {
1930 if (is_object($this->modules[$key])
1931 && method_exists($this->modules[$key], $method)
1938 if (!is_null($module)) {
1939 return call_user_func_array(
array(&$this->modules[$module], $method),
$params);
1941 trigger_error(sprintf(
'Call to undefined function: %s::%s().', get_class($this), $method), E_USER_ERROR);
1957 $this->debug(
'Starting transaction', __FUNCTION__,
array(
'is_manip' =>
true,
'savepoint' => $savepoint));
1959 'transactions are not supported', __FUNCTION__);
1978 $this->debug(
'Committing transaction/savepoint', __FUNCTION__,
array(
'is_manip' =>
true,
'savepoint' => $savepoint));
1980 'commiting transactions is not supported', __FUNCTION__);
1999 $this->debug(
'Rolling back transaction/savepoint', __FUNCTION__,
array(
'is_manip' =>
true,
'savepoint' => $savepoint));
2001 'rolling back transactions is not supported', __FUNCTION__);
2020 if (!$ignore_nested && isset($this->nested_transaction_counter)) {
2021 return $this->nested_transaction_counter;
2023 return $this->in_transaction;
2047 $this->debug(
'Setting transaction isolation level', __FUNCTION__,
array(
'is_manip' =>
true));
2049 'isolation level setting is not supported', __FUNCTION__);
2070 if ($this->in_transaction) {
2071 ++$this->nested_transaction_counter;
2072 $savepoint = sprintf($this->options[
'savepoint_format'], $this->nested_transaction_counter);
2073 if ($this->supports(
'savepoints') && $savepoint) {
2074 return $this->beginTransaction($savepoint);
2078 $this->has_transaction_error =
false;
2079 $result = $this->beginTransaction();
2080 $this->nested_transaction_counter = 1;
2106 if ($this->nested_transaction_counter > 1) {
2107 $savepoint = sprintf($this->options[
'savepoint_format'], $this->nested_transaction_counter);
2108 if ($this->supports(
'savepoints') && $savepoint) {
2109 if ($force_rollback || $this->has_transaction_error) {
2110 $result = $this->rollback($savepoint);
2113 $this->has_transaction_error =
false;
2116 $result = $this->commit($savepoint);
2121 --$this->nested_transaction_counter;
2125 $this->nested_transaction_counter = null;
2129 if ($this->in_transaction) {
2130 if ($force_rollback || $this->has_transaction_error) {
2139 $this->has_transaction_error =
false;
2164 $error = $this->has_transaction_error ? $this->has_transaction_error :
true;
2168 $this->has_transaction_error =
$error;
2169 if (!$immediately) {
2172 return $this->rollback();
2193 return $this->has_transaction_error;
2207 'method not implemented', __FUNCTION__);
2224 'method not implemented', __FUNCTION__);
2243 $this->connection = 0;
2244 $this->connected_dsn =
array();
2245 $this->connected_database_name =
'';
2246 $this->opened_persistent = null;
2247 $this->connected_server_info =
'';
2248 $this->in_transaction = null;
2249 $this->nested_transaction_counter = null;
2267 $previous_database_name = (isset($this->database_name)) ? $this->database_name :
'';
2268 $this->database_name = $name;
2269 $this->disconnect(
false);
2270 return $previous_database_name;
2285 return $this->database_name;
2302 $dsn_default =
$GLOBALS[
'_MDB2_dsninfo_default'];
2304 if (array_key_exists(
'database', $dsn)) {
2305 $this->database_name = $dsn[
'database'];
2306 unset($dsn[
'database']);
2308 $this->dsn = array_merge($dsn_default, $dsn);
2309 return $this->disconnect(
false);
2325 function getDSN($type =
'string', $hidepw =
false)
2327 $dsn = array_merge(
$GLOBALS[
'_MDB2_dsninfo_default'], $this->dsn);
2328 $dsn[
'phptype'] = $this->phptype;
2329 $dsn[
'database'] = $this->database_name;
2331 $dsn[
'password'] = $hidepw;
2336 $dsn = $dsn[
'phptype'].
2337 ($dsn[
'dbsyntax'] ? (
'('.$dsn[
'dbsyntax'].
')') :
'').
2338 '://'.$dsn[
'username'].
':'.
2339 $dsn[
'password'].
'@'.$dsn[
'hostspec'].
2340 ($dsn[
'port'] ? (
':'.$dsn[
'port']) :
'').
2341 '/'.$dsn[
'database'];
2367 $offset = $this->offset;
2368 $limit = $this->limit;
2369 $this->offset = $this->limit = 0;
2370 $query = $this->_modifyQuery(
$query, $is_manip, $limit, $offset);
2372 $connection = $this->getConnection();
2377 $result =& $this->_doQuery(
$query, $is_manip, $connection,
false);
2383 $affected_rows = $this->_affectedRows($connection,
$result);
2384 return $affected_rows;
2386 $result =& $this->_wrapResult(
$result, $types,
true,
false, $limit, $offset);
2424 function &
_doQuery(
$query, $is_manip =
false, $connection = null, $database_name = null)
2426 $this->last_query =
$query;
2427 $result = $this->debug(
$query,
'query',
array(
'is_manip' => $is_manip,
'when' =>
'pre'));
2435 'method not implemented', __FUNCTION__);
2455 'method not implemented', __FUNCTION__);
2472 $offset = $this->offset;
2473 $limit = $this->limit;
2474 $this->offset = $this->limit = 0;
2475 $query = $this->_modifyQuery(
$query,
true, $limit, $offset);
2477 $connection = $this->getConnection();
2482 $result =& $this->_doQuery(
$query,
true, $connection, $this->database_name);
2487 $affectedRows = $this->_affectedRows($connection,
$result);
2488 return $affectedRows;
2507 function &
query(
$query, $types = null, $result_class =
true, $result_wrap_class =
false)
2509 $offset = $this->offset;
2510 $limit = $this->limit;
2511 $this->offset = $this->limit = 0;
2512 $query = $this->_modifyQuery(
$query,
false, $limit, $offset);
2514 $connection = $this->getConnection();
2519 $result =& $this->_doQuery(
$query,
false, $connection, $this->database_name);
2524 $result =& $this->_wrapResult(
$result, $types, $result_class, $result_wrap_class, $limit, $offset);
2547 $result_wrap_class =
false, $limit = null, $offset = null)
2549 if ($types ===
true) {
2550 if ($this->supports(
'result_introspection')) {
2551 $this->loadModule(
'Reverse', null,
true);
2552 $tableInfo = $this->reverse->tableInfo(
$result);
2557 foreach ($tableInfo as $field) {
2558 $types[] = $field[
'mdb2type'];
2565 if ($result_class ===
true) {
2566 $result_class = $this->options[
'result_buffering']
2567 ? $this->options[
'buffered_result_class'] : $this->options[
'result_class'];
2570 if ($result_class) {
2571 $class_name = sprintf($result_class, $this->phptype);
2574 'result class does not exist '.$class_name, __FUNCTION__);
2580 'result class is not extended from MDB2_Result_Common', __FUNCTION__);
2583 if (!empty($types)) {
2584 $err =
$result->setResultTypes($types);
2591 if ($result_wrap_class ===
true) {
2592 $result_wrap_class = $this->options[
'result_wrap_class'];
2594 if ($result_wrap_class) {
2597 'result wrap class does not exist '.$result_wrap_class, __FUNCTION__);
2620 'method not implemented', __FUNCTION__);
2638 if (!$this->supports(
'limit_queries')) {
2640 'limit is not supported by this driver', __FUNCTION__);
2642 $limit = (int)$limit;
2645 'it was not specified a valid selected range row limit', __FUNCTION__);
2647 $this->limit = $limit;
2648 if (!is_null($offset)) {
2649 $offset = (int)$offset;
2652 'it was not specified a valid first selected range row', __FUNCTION__);
2654 $this->offset = $offset;
2676 if ($this->supports(
'sub_selects') ===
true) {
2680 if (!$this->supports(
'sub_selects')) {
2682 'method not implemented', __FUNCTION__);
2685 $col = $this->queryCol(
$query, $type);
2689 if (!is_array($col) || count($col) == 0) {
2693 $this->loadModule(
'Datatype', null,
true);
2694 return $this->datatype->implodeArray($col, $type);
2696 return implode(
', ', $col);
2767 if (!$this->supports(
'replace')) {
2769 'replace query is not supported', __FUNCTION__);
2771 $count = count($fields);
2772 $condition = $values =
array();
2773 for ($colnum = 0, reset($fields); $colnum < $count; next($fields), $colnum++) {
2774 $name = key($fields);
2775 if (isset($fields[$name][
'null']) && $fields[$name][
'null']) {
2778 $type = isset($fields[$name][
'type']) ? $fields[$name][
'type'] : null;
2779 $value = $this->quote($fields[$name][
'value'], $type);
2781 $values[$name] = $value;
2782 if (isset($fields[$name][
'key']) && $fields[$name][
'key']) {
2783 if ($value ===
'NULL') {
2785 'key value '.$name.
' may not be NULL', __FUNCTION__);
2787 $condition[] = $name .
'=' . $value;
2790 if (empty($condition)) {
2792 'not specified which fields are keys', __FUNCTION__);
2796 $in_transaction = $this->in_transaction;
2801 $connection = $this->getConnection();
2806 $condition =
' WHERE '.implode(
' AND ', $condition);
2807 $query =
"DELETE FROM $table$condition";
2810 $affected_rows = $this->_affectedRows($connection,
$result);
2811 $insert = implode(
', ', array_keys($values));
2812 $values = implode(
', ', $values);
2813 $query =
"INSERT INTO $table ($insert) VALUES ($values)";
2816 $affected_rows += $this->_affectedRows($connection,
$result);;
2820 if (!$in_transaction) {
2832 return $affected_rows;
2863 $offset = $this->offset;
2864 $limit = $this->limit;
2865 $this->offset = $this->limit = 0;
2866 $result = $this->debug(
$query, __FUNCTION__,
array(
'is_manip' => $is_manip,
'when' =>
'pre'));
2873 $placeholder_type_guess = $placeholder_type = null;
2876 $positions =
array();
2878 $ignores = $this->sql_comments;
2879 $ignores[] = $this->string_quoting;
2880 $ignores[] = $this->identifier_quoting;
2881 while ($position < strlen(
$query)) {
2882 $q_position = strpos(
$query, $question, $position);
2883 $c_position = strpos(
$query, $colon, $position);
2884 if ($q_position && $c_position) {
2885 $p_position = min($q_position, $c_position);
2886 } elseif ($q_position) {
2887 $p_position = $q_position;
2888 } elseif ($c_position) {
2889 $p_position = $c_position;
2893 if (is_null($placeholder_type)) {
2894 $placeholder_type_guess =
$query[$p_position];
2897 $new_pos = $this->_skipDelimitedStrings(
$query, $position, $p_position);
2901 if ($new_pos != $position) {
2902 $position = $new_pos;
2906 if (
$query[$position] == $placeholder_type_guess) {
2907 if (is_null($placeholder_type)) {
2908 $placeholder_type =
$query[$p_position];
2909 $question = $colon = $placeholder_type;
2910 if (!empty($types) && is_array($types)) {
2911 if ($placeholder_type ==
':') {
2912 if (is_int(key($types))) {
2913 $types_tmp = $types;
2918 $types = array_values($types);
2922 if ($placeholder_type ==
':') {
2923 $parameter = preg_replace(
'/^.{'.($position+1).
'}([a-z0-9_]+).*$/si',
'\\1',
$query);
2924 if ($parameter ===
'') {
2926 'named parameter with an empty name', __FUNCTION__);
2929 $positions[$p_position] = $parameter;
2930 $query = substr_replace(
$query,
'?', $position, strlen($parameter)+1);
2932 if (isset($count) && isset($types_tmp[++$count])) {
2933 $types[$parameter] = $types_tmp[$count];
2936 $positions[$p_position] = count($positions);
2938 $position = $p_position + 1;
2940 $position = $p_position;
2943 $class_name =
'MDB2_Statement_'.$this->phptype;
2945 $obj =
new $class_name($this, $statement, $positions,
$query, $types, $result_types, $is_manip, $limit, $offset);
2946 $this->debug(
$query, __FUNCTION__,
array(
'is_manip' => $is_manip,
'when' =>
'post',
'result' => $obj));
2970 $ignores = $this->sql_comments;
2971 $ignores[] = $this->string_quoting;
2972 $ignores[] = $this->identifier_quoting;
2974 foreach ($ignores as
$ignore) {
2975 if (!empty($ignore[
'start'])) {
2976 if (is_int($start_quote = strpos(
$query, $ignore[
'start'], $position)) && $start_quote < $p_position) {
2977 $end_quote = $start_quote;
2979 if (!is_int($end_quote = strpos(
$query, $ignore[
'end'], $end_quote + 1))) {
2980 if ($ignore[
'end'] ===
"\n") {
2981 $end_quote = strlen(
$query) - 1;
2984 'query with an unterminated text string specified', __FUNCTION__);
2988 }
while ($ignore[
'escape'] &&
$query[($end_quote - 1)] == $ignore[
'escape']);
2989 $position = $end_quote + 1;
3014 function quote($value, $type = null, $quote =
true, $escape_wildcards =
false)
3016 $result = $this->loadModule(
'Datatype', null,
true);
3021 return $this->datatype->quote($value, $type, $quote, $escape_wildcards);
3042 $result = $this->loadModule(
'Datatype', null,
true);
3046 return $this->datatype->getDeclaration($type, $name, $field);
3064 $result = $this->loadModule(
'Datatype', null,
true);
3068 return $this->datatype->compareDefinition($current, $previous);
3088 if (array_key_exists($feature, $this->supported)) {
3089 return $this->supported[$feature];
3092 "unknown support feature $feature", __FUNCTION__);
3109 return sprintf($this->options[
'seqname_format'],
3110 preg_replace(
'/[^a-z0-9_\$.]/i',
'_', $sqn));
3127 return sprintf($this->options[
'idxname_format'],
3128 preg_replace(
'/[^a-z0-9_\$]/i',
'_', $idx));
3147 'method not implemented', __FUNCTION__);
3167 'method not implemented', __FUNCTION__);
3184 $this->warnings[] =
'database does not support getting current 3185 sequence value, the sequence value was incremented';
3186 return $this->nextID($seq_name);
3215 $one =
$result->fetchOne($colnum);
3276 $col =
$result->fetchCol($colnum);
3309 $rekey =
false, $force_array =
false, $group =
false)
3316 $all =
$result->fetchAll($fetchmode, $rekey, $force_array, $group);
3340 require_once(
'./Services/Database/interfaces/interface.ilDBStatement.php');
3358 var $offset_count = 0;
3372 $this->offset = $offset;
3373 $this->limit = max(0, $limit - 1);
3378 return $this->fetchRow($fetch_mode);
3399 $this->__construct($db, $result, $limit, $offset);
3428 $load = $this->db->loadModule(
'Datatype', null,
true);
3432 $types = $this->db->datatype->checkResultTypes($types);
3436 $this->types = $types;
3454 $target_rownum = $rownum - 1;
3455 if ($this->rownum > $target_rownum) {
3457 'seeking to previous rows not implemented', __FUNCTION__);
3459 while ($this->rownum < $target_rownum) {
3481 'method not implemented', __FUNCTION__);
3501 $row = $this->fetchRow($fetchmode, $rownum);
3505 if (!array_key_exists($colnum,
$row)) {
3507 'column is not defined in the result set: '.$colnum, __FUNCTION__);
3509 return $row[$colnum];
3528 $row = $this->fetchRow($fetchmode);
3529 if (is_array(
$row)) {
3530 if (!array_key_exists($colnum,
$row)) {
3532 'column is not defined in the result set: '.$colnum, __FUNCTION__);
3536 }
while (is_array(
$row = $this->fetchRow($fetchmode)));
3571 $force_array =
false, $group =
false)
3574 $row = $this->fetchRow($fetchmode);
3581 $shift_array = $rekey ? false : null;
3582 if (!is_null($shift_array)) {
3583 if (is_object(
$row)) {
3584 $colnum = count(get_object_vars(
$row));
3586 $colnum = count(
$row);
3590 'rekey feature requires atleast 2 column', __FUNCTION__);
3592 $shift_array = (!$force_array && $colnum == 2);
3597 if (is_object(
$row)) {
3598 $arr = get_object_vars(
$row);
3600 unset(
$row->{$key});
3606 $key = array_shift(
$row);
3613 $all[$key][] =
$row;
3617 }
while ((
$row = $this->fetchRow($fetchmode)));
3620 foreach (
$row as $key => $val) {
3621 $all[$key][] = $val;
3623 }
while ((
$row = $this->fetchRow($fetchmode)));
3627 }
while ((
$row = $this->fetchRow($fetchmode)));
3643 return $this->rownum + 1;
3659 'method not implemented', __FUNCTION__);
3675 'method not implemented', __FUNCTION__);
3696 if (!isset($this->column_names)) {
3697 $result = $this->_getColumnNames();
3701 $this->column_names =
$result;
3704 return array_flip($this->column_names);
3706 return $this->column_names;
3725 'method not implemented', __FUNCTION__);
3742 'method not implemented', __FUNCTION__);
3777 $column_names = $this->getColumnNames();
3779 if ($this->db->options[
'field_case'] == CASE_LOWER) {
3787 $this->values[
$column] =& $value;
3788 if (!is_null($type)) {
3789 $this->types[
$column] = $type;
3810 if (array_key_exists(
$column, $this->values)) {
3811 $this->values[
$column] = $value;
3829 $this->result =
false;
3840 $res = $this->result->execute($a_data);
3842 throw new ilDatabaseException(
"There was an MDB2 error executing the prepared query: ".$this->result->getMessage());
3869 foreach (
$row as $key => $value) {
3870 $this->$key = &
$row[$key];
3884 $this->__construct(
$row);
3920 function __construct(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip =
false, $limit = null, $offset = null)
3923 $this->statement =& $statement;
3924 $this->positions = $positions;
3926 $this->types = (
array)$types;
3927 $this->result_types = (
array)$result_types;
3928 $this->limit = $limit;
3929 $this->is_manip = $is_manip;
3930 $this->offset = $offset;
3939 function MDB2_Statement_Common(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip =
false, $limit = null, $offset = null)
3941 $this->__construct($db, $statement, $positions, $query, $types, $result_types, $is_manip, $limit, $offset);
3962 if (!is_numeric($parameter)) {
3963 $parameter = preg_replace(
'/^:(.*)$/',
'\\1', $parameter);
3965 if (!in_array($parameter, $this->positions)) {
3967 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
3969 $this->values[$parameter] = $value;
3970 if (!is_null($type)) {
3971 $this->types[$parameter] = $type;
3994 $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
3995 $parameters = array_keys($values);
3996 foreach ($parameters as $key => $parameter) {
3997 $err = $this->bindValue($parameter, $values[$parameter], $types[$key]);
4023 if (!is_numeric($parameter)) {
4024 $parameter = preg_replace(
'/^:(.*)$/',
'\\1', $parameter);
4026 if (!in_array($parameter, $this->positions)) {
4028 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
4030 $this->values[$parameter] =& $value;
4031 if (!is_null($type)) {
4032 $this->types[$parameter] = $type;
4055 $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null);
4056 $parameters = array_keys($values);
4057 foreach ($parameters as $key => $parameter) {
4058 $err = $this->bindParam($parameter, $values[$parameter], $types[$key]);
4082 function &
execute($values = null, $result_class =
true, $result_wrap_class =
false)
4084 if (is_null($this->positions)) {
4085 return $this->db->raiseError(
MDB2_ERROR, null, null,
4086 'Prepared statement has already been freed', __FUNCTION__);
4089 $values = (
array)$values;
4090 if (!empty($values)) {
4091 $err = $this->bindValueArray($values);
4093 return $this->db->raiseError(
MDB2_ERROR, null, null,
4094 'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
4097 $result =& $this->_execute($result_class, $result_wrap_class);
4114 function &
_execute($result_class =
true, $result_wrap_class =
false)
4119 foreach ($this->positions as $current_position => $parameter) {
4120 if (!array_key_exists($parameter, $this->values)) {
4122 'Unable to bind to missing placeholder: '.$parameter, __FUNCTION__);
4124 $value = $this->values[$parameter];
4125 $query.= substr($this->query, $last_position, $current_position - $last_position);
4126 if (!isset($value)) {
4127 $value_quoted =
'NULL';
4129 $type = !empty($this->types[$parameter]) ? $this->types[$parameter] : null;
4130 $value_quoted = $this->db->quote($value, $type);
4132 return $value_quoted;
4135 $query.= $value_quoted;
4136 $last_position = $current_position + 1;
4138 $query.= substr($this->query, $last_position);
4140 $this->db->offset = $this->offset;
4141 $this->db->limit = $this->limit;
4142 if ($this->is_manip) {
4143 $result = $this->db->exec($query);
4145 $result =& $this->db->query($query, $this->result_types, $result_class, $result_wrap_class);
4162 if (is_null($this->positions)) {
4163 return $this->db->raiseError(
MDB2_ERROR, null, null,
4164 'Prepared statement has already been freed', __FUNCTION__);
4167 $this->statement = null;
4168 $this->positions = null;
4169 $this->query = null;
4170 $this->types = null;
4171 $this->result_types = null;
4172 $this->limit = null;
4173 $this->is_manip = null;
4174 $this->offset = null;
4175 $this->values = null;
4214 $this->db_index = $db_index;
4225 $this->__construct($db_index);
4240 if (isset(
$GLOBALS[
'_MDB2_databases'][$this->db_index])) {
4244 'could not find MDB2 instance');
4265 reset(
$GLOBALS[
'_MDB2_databases']);
4266 while (next(
$GLOBALS[
'_MDB2_databases'])) {
4267 $key = key(
$GLOBALS[
'_MDB2_databases']);
4268 if (
$GLOBALS[
'_MDB2_databases'][$key]->opened_persistent
4269 &&
$GLOBALS[
'_MDB2_databases'][$key]->in_transaction
4271 $GLOBALS[
'_MDB2_databases'][$key]->rollback();
4297 $db->debug_output.= $scope.
'('.$db->db_index.
'): ';
4298 $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.
while(false !==( $line=fgets( $in))) if(! $columns) $ignore
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
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.
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
if(!is_array($argv)) $options
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
& raiseError($code=null, $mode=null, $options=null, $userinfo=null, $method=null)
This method is used to communicate an error and invoke error callbacks etc.
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($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
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.
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.
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