query = mysql_query($s_sql); $this->num_rows = @mysql_num_rows($this->query); } public function fetch_assoc(){ return(mysql_fetch_assoc($this->query)); } public function fetch_array(){ return(mysql_fetch_array($this->query)); } public function fetch_row(){ return(mysql_fetch_row($this->query)); } } class db_connect{ protected $host = "localhost"; protected $user = "username"; protected $pass = "password"; protected $data = "database"; public function __construct(){ $connect = mysql_connect($this->host, $this->user, $this->pass) or die("Couldn't connect to MySQL.\n" . mysql_error()); $dbpick = mysql_select_db($this->data, $connect) or die("Couldn't select MySQL database.\n" . mysql_error()); } public function query($sql){ return(new q_fns($sql)); } } /*Implementation: $mysql = new db_connect; $result = $mysql->query("select * from `table`"); $num_rows = $result->num_rows; while($row = $result->fetch_assoc()){ echo $row['field']; } */ ?>