* @since Beta 2.0 * @return void **/ function database($db_host, $db_user, $db_pass, $db_name, $db_port, $db_socket) { $this->get = $_GET; $this->post = $_POST; $this->host = $db_host; $this->user = $db_user; $this->pass = $db_pass; $this->db = $db_name; $this->port = $db_port; } /** * Retrieves debug information about a query * * @param string $query Query to debug * @access protected * @author Jason Warner * @since Beta 2.0 * @return void **/ function debug($query) { $this->querylog[] = $query; $mtime = explode(' ', microtime()); $starttime = $mtime[1] + $mtime[0]; $data = $this->get_debug_info($query); $mtime = explode(' ', microtime()); $querytime = ($mtime[1] + $mtime[0]) - $starttime; $this->querytime += $querytime; $data['querytime'] = $querytime; $data['query'] = $query; $this->querydebug[] = $data; } /** * Runs an EXPLAIN or similar on a query * Interface version * * @param string $query Query to debug * @access protected * @return void **/ function get_debug_info($query) { return array(); } /** * Retrieves the insert ID of the last executed query * Interface version * * @param string $table Table name - unused * @return int Insert ID **/ function insert_id($table) { return null; } /** * Executes a query * Interface version * * @param string $query SQL query * @return resource Executed query **/ function query($query) { return null; } /** * Executes a query and fetches it into an array * * @param string $query SQL query * @param string $args Data to pass into query as escaped strings * @author Jason Warner * @since Beta 2.0 * @return array Fetched rows **/ function fetch($query) { $args = array(); if (is_array($query)) { $args = $query; // only use arg 1 } else { $args = func_get_args(); } return $this->nqfetch($this->query($args)); } /** * Fetches an executed query into an array * Interface version * * @param resource $query Executed SQL query * @return array Fetched rows **/ function nqfetch($query) { return array(); } /** * Gets the number of rows retrieved by a SELECT * Interface version * * @param resource $query Executed SQL query * @return int Number of retrieved rows **/ function num_rows($query) { return 0; } /** * Clones a row * * @param string $table MySQL table to select from * @param string $unique_col Name of a unique column by which to find the row. This column is not given an explicit value in the cloned row. * @param string $unique_id The value of $unique_col in the original row * @author Jason Warner * @since Beta 4.0 * @return void */ function clone_row($table, $unique_col, $unique_id) { $cols = null; $vals = null; $result = $this->fetch('SELECT * FROM ' . $table . ' WHERE ' . $unique_col . '=' . $unique_id); foreach ($result as $col => $val) { if ($col == $unique_col) { continue; } $cols .= $col . ', '; $vals .= '"' . $this->escape($val) . '", '; } $this->query('INSERT INTO ' . $table . ' (' . substr($cols, 0, -2) . ') VALUES (' . substr($vals, 0, -2) . ')'); } /** * Gets the number of rows affected by the last executed UPDATE * Interface version * * @return int Number of affected rows **/ function aff_rows() { return 0; } /** * Returns a escaped string * * @since 1.3.0 * @return string A string with the quotes and other charaters escaped * @param string $string The string to escape **/ function escape($string) { return addslashes($string); } /** * Puts the data into the query using the escape function * * @param string $query SQL query * @param string $args Data to pass into query as escaped strings * @return string Formatted query **/ function _format_query($query) { // Format the query string $args = array(); if (is_array($query)) { $args = $query; // only use arg 1 } else { $args = func_get_args(); } $query = array_shift($args); for($i=0; $iescape($args[$i]); } array_unshift($args,$query); return call_user_func_array('sprintf',$args); } } ?>