http://www.php.net/pdo All the cool kids are doing it. On Saturday 09 February 2008, nihilism machine wrote: > Looking to really beef up my DB class, any suggestions for functions > to add that will be more time saving for a web 2.0 app, or ways to > improve existing methods? thank you everyone in advance. > > <?php > > class db { > > // Members > public $db_user = ""; > public $db_pass = ""; > public $db_name = ""; > public $db_server = ""; > public $link; > public $result_id; > > // Methods > public function __construct() { > $this->connect(); > } > > // Connect to MySQL Server > public function connect() { > $this->link = mysql_connect($this->db_server,$this->db_user,$this- > > >db_pass) or die("Error: Cannot Connect to DataBase"); > > mysql_select_db($this->db_name,$this->link) or die("Error: Cannot > Select Database (" . $this->db_name . ")"); > } > > // MySQL Query > public function query($sql) { > $this->result_id = mysql_query($sql); > return $this->fetch_rows(); > } > > // MySQL Query > public function insert($sql) { > $this->result_id = mysql_query($sql); > return $this->select_id; > } > > // MySQL Fetch Rows > public function fetch_rows() { > $rows = array(); > if($this->result_id){ > while($row = mysql_fetch_object($this->result_id)) { > $rows[] = $row; > } > } > return $rows; > } > > // MySQL Affected Rows > public function num_rows() { > return mysql_num_rows($this->link); > } > > // MySQL Affected Rows > public function select_id() { > return mysql_insert_id($this->link); > } > > // Disconnect from MySQL Server > public function disconnect() { > mysql_close($this->link); > } > > // Terminator Style Function simply in coolness > public function Terminator($tbl) { > } > > // Destruct! > public function __destruct() { > $this->disconnect(); > } > } > > ?> -- Larry Garfield AIM: LOLG42 larry@xxxxxxxxxxxxxxxx ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php