_link = mysql_connect($host, $user); else: @ $this->_link = mysql_connect($host, $user, $pass); endif; if (!$this->_link): $this->_error[TRUE] = -1; $this->_error[FALSE] = "Failed connection to MySQL host [$host] as [$user] (using password: ".(is_null($pass) ? "NO" : "YES").")"; else: @ $success = mysql_select_db($db_name, $this->_link); if (!$success): $this->_error[TRUE] = mysql_errno($this->_link); $this->_error[FALSE] = mysql_error($this->_link); @ mysql_close($this->_link); unset($this->_link); endif; endif; } /* OOMDB::OOMDB() */ function __destructor () { mysql_close($this->_link); } function link () { return $this->_link; } function error ($numeric = FALSE) { return (is_bool($numeric) ? $this->_error[$numeric] : $this->_error); } function is_empty () { return is_null($this->_result); } function issue ($query) { $result = mysql_query($query, $this->link()); if (mysql_error($this->link())): $ret = NULL; $this->_error[FALSE] = mysql_error($this->link()); $this->_error[TRUE] = mysql_errno($this->link()); else: $ret = mysql_affected_rows($this->link()); endif; $this->_result = NULL; if (is_resource($result)): while ($db_row = mysql_fetch_assoc($result)): $this->_result[] = $db_row; endwhile; mysql_free_result($result); endif; return ($ret); } function result () { return $this->_result; } } /* class OOMDB */