// DB Constructor - connects to the server and selects a database
function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
+ return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost);
+ }
+
+ function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
+ register_shutdown_function(array(&$this, "__destruct"));
+
$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
if (!$this->dbh) {
$this->bail("
$this->select($dbname);
}
+ function __destruct() {
+ return true;
+ }
+
// ==================================================================
// Select a DB (if another one needs to be selected)
// Kill cached query results
function flush() {
- $this->last_result = null;
+ $this->last_result = array();
$this->col_info = null;
$this->last_query = null;
}
// Basic Query - see docs for more detail
function query($query) {
+ // filter the query, if filters are available
+ // NOTE: some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
+ if ( function_exists('apply_filters') )
+ $query = apply_filters('query', $query);
+
// initialise return
$return_val = 0;
$this->flush();