Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Donators{
- protected $user;
- protected $pass;
- protected $dbname;
- protected $dbhost;
- protected $dbh; //db handle
- public function __construct($user,$pass,$dbname,$dbhost,$dbtable){
- $this->user = $user;
- $this->pass = $pass;
- $this->dbname = $dbname;
- $this->dbhost = $dbhost;
- }
- protected function connect(){
- $this->dbh = mysql_connect($this->dbhost,$this->user,$this->pass);
- if (!is_resource($this->dbh))
- throw new Exception;
- if (!mysql_select_db($this->dbname,$this->dbh))
- throw new Exception;
- }
- protected function execute($query){
- if (!$this->dbh) {
- $this->connect();
- }
- $ret = mysql_query($query,$this->dbh);
- if (!$ret){
- throw new Exception;
- } else if (!is_resource($ret)) {
- return TRUE;
- } else {
- return $ret;
- }
- }
- public function get_list($table){
- $q = "SELECT * FROM " . $table;
- $qresult = $this->execute($q);
- $retval = array();
- while ($row = mysql_fetch_assoc($qresult)){
- $retval[] = $row;
- }
- return $retval;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement