peardb_wrapper.php
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 576 行 · 第 1/2 页
PHP
576 行
} }}class MDB_PEAR_PROXY{ var $MDB_object; function MDB_PEAR_PROXY($MDB_object) { $this->MDB_object = $MDB_object; $this->MDB_object->option['sequence_col_name'] = 'id'; } function connect($dsninfo, $persistent = FALSE) { return($this->MDB_object->connect($dsninfo, $persistent)); } function disconnect() { return($this->MDB_object->disconnect()); } function quoteString($string) { $string = $this->_quote($string); if ($string{0} == "'") { return substr($string, 1, -1); } return($string); } function quote($string) { if ($string === NULL) { return 'NULL'; } return($this->MDB_object->_quote($string)); } function provides($feature) { return($this->MDB_object->support($feature)); } function errorCode($nativecode) { return($this->MDB_object->errorCode($nativecode)); } function errorMessage($dbcode) { return($this->MDB_object->errorMessage($dbcode)); } function &raiseError($code = DB_ERROR, $mode = NULL, $options = NULL, $userinfo = NULL, $nativecode = NULL) { return($this->MDB_object->raiseError($code = DB_ERROR, $mode, $options, $userinfo, $nativecode)); } function setFetchMode($fetchmode, $object_class = NULL) { return($this->MDB_object->setFetchMode($fetchmode, $object_class)); } function setOption($option, $value) { return($this->MDB_object->setOption($option, $value)); } function getOption($option) { return($this->MDB_object->getOption($option)); } function prepare($query) { return($this->MDB_object->prepareQuery($query)); } function autoPrepare($table, $table_fields, $mode = DB_AUTOQUERY_INSERT, $where = false) { $query = $this->buildManipSQL($table, $table_fields, $mode, $where); return($this->prepare($query)); } function autoExecute($table, $fields_values, $mode = DB_AUTOQUERY_INSERT, $where = false) { $sth = $this->autoPrepare($table, array_keys($fields_values), $mode, $where); return($this->execute($sth, array_values($fields_values))); } function buildManipSQL($table, $table_fields, $mode, $where = false) { if (count($table_fields) == 0) { $this->raiseError(DB_ERROR_NEED_MORE_DATA); } $first = true; switch ($mode) { case DB_AUTOQUERY_INSERT: $values = ''; $names = ''; while (list(, $value) = each($table_fields)) { if ($first) { $first = false; } else { $names .= ','; $values .= ','; } $names .= $value; $values .= '?'; } return "INSERT INTO $table ($names) VALUES ($values)"; break; case DB_AUTOQUERY_UPDATE: $set = ''; while (list(, $value) = each($table_fields)) { if ($first) { $first = false; } else { $set .= ','; } $set .= "$value = ?"; } $sql = "UPDATE $table SET $set"; if ($where) { $sql .= " WHERE $where"; } return($sql); break; default: $this->raiseError(DB_ERROR_SYNTAX); } } function execute($stmt, $data = FALSE) { $result = $this->MDB_object->execute($stmt, NULL, $data); if (MDB::isError($result) || $result === DB_OK) { return($result); } else { return new DB_result($this->MDB_object, $result); } } function executeMultiple( $stmt, &$data ) { return($this->MDB_object->executeMultiple($stmt, NULL, $data)); } function &query($query, $params = array()) { if (sizeof($params) > 0) { $sth = $this->MDB_object->prepare($query); if (MDB::isError($sth)) { return($sth); } return($this->MDB_object->execute($sth, $params)); } else { $result = $this->MDB_object->query($query); if (MDB::isError($result) || $result === DB_OK) { return($result); } else { return new DB_result($this->MDB_object, $result); } } } function simpleQuery($query) { return($this->MDB_object->query($query)); } function limitQuery($query, $from, $count) { $result = $this->MDB_object->limitQuery($query, NULL, $from, $count); if (MDB::isError($result) || $result === DB_OK) { return($result); } else { return new DB_result($this->MDB_object, $result); } } function &getOne($query, $params = array()) { return($this->MDB_object->getOne($query, NULL, $params)); } function &getRow($query, $params = NULL, $fetchmode = DB_FETCHMODE_DEFAULT) { return($this->MDB_object->getRow($query, NULL, $params, NULL, $fetchmode)); } function &getCol($query, $col = 0, $params = array()) { return($this->MDB_object->getCol($query, NULL, $params, NULL, $col)); } function &getAssoc($query, $force_array = FALSE, $params = array(), $fetchmode = DB_FETCHMODE_ORDERED, $group = FALSE) { return($this->MDB_object->getAssoc($query, NULL, $params, NULL, $fetchmode, $force_array, $group)); } function &getAll($query, $params = NULL, $fetchmode = DB_FETCHMODE_DEFAULT) { return($this->MDB_object->getAll($query, NULL, $params, NULL, $fetchmode)); } function autoCommit($onoff = FALSE) { return($this->MDB_object->autoCommit($onoff)); } function commit() { return($this->MDB_object->commit()); } function rollback() { return($this->MDB_object->rollback()); } function numRows($result) { return($this->MDB_object->numRows($result)); } function affectedRows() { return($this->MDB_object->affectedRows()); } function errorNative() { return($this->MDB_object->errorNative()); } function nextId($seq_name, $ondemand = TRUE) { return($this->MDB_object->nextId($seq_name, $ondemand)); } function createSequence($seq_name) { return($this->MDB_object->createSequence($seq_name, 1)); } function dropSequence($seq_name) { return($this->MDB_object->dropSequence($seq_name)); } function tableInfo($result, $mode = NULL) { return($this->MDB_object->tableInfo($result, $mode)); } function getTables() { return($this->getListOf('tables')); } function getListOf($type) { switch ($type) { case 'tables': return($this->MDB_object->listTables()); case 'views': return($this->MDB_object->listViews()); case 'users': return($this->MDB_object->listUsers()); case 'functions': return($this->MDB_object->listFunctions()); case 'databases': return($this->MDB_object->listDatabases()); default: return($this->raiseError(DB_ERROR_UNSUPPORTED)); } }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?