dbConn = mysql_connect( $dbHost, $dbUser, $dbPass ) or die(mysql_error()); mysql_select_db($dbName, $this->dbConn) or die(mysql_error()); } public function prep($sql){ $this->dbSql = $sql; } // loads values into sql statement. public function bind($hook, $value){ $this->dbBind[$hook] = $this->escape($value); } // used to fix any malformed SQL strings. private function escape($value){ if(get_magic_quotes_gpc()) $value = stripslashes($value); return mysql_real_escape_string($value, $this->dbConn); } public function run(){ $sql = $this->dbSql; if(is_array($this->dbBind)){ foreach($this->dbBind as $hook => $value){ $sql = str_replace($hook, "'" . $value . "'", $sql); } } $this->dbQuery = mysql_query($sql) or die(mysql_error()); $this->dbBind = array(); return $this->numRows(); } /* 2.0.2 Helper Methods */ public function fetchAll($type = MYSQL_ASSOC){ $tmpArr = array(); while($row = mysql_fetch_array($this->dbQuery, $type)){ $tmpArr[] = $row; } return $tmpArr; } public function fetchAssoc(){ return mysql_fetch_assoc($this->dbQuery); } public function numRows(){ return mysql_num_rows($this->dbQuery); } public function insertId(){ return mysql_insert_id($this->dbConn); } } ?>