note 74505 added to ref.mysql

From: Date: Sat, 14 Apr 2007 18:20:54 +0000
Subject: note 74505 added to ref.mysql
Groups: php.notes 
Request: Send a blank email to php-notes+get-125399@lists.php.net to get a copy of this message
This PHP5-only class is used so that $db isn't passed. Kudos to arjen at queek dot nl for example. <?php class SQL { private $db; public function __construct($host="localhost",$user="root",$pass="",$db="") { $this->db = @mysql_connect($host, $user, $pass); if(!$this->db) die(@mysql_error()); if($db != "") $dbs = @mysql_select_db($db); if(!$dbs) die(@mysql_error()); } public function __destruct() { @mysql_close($db); } public function __call($function, $arguments) { array_push($arguments, $this->db); $return = call_user_func_array("mysql_".$function, $arguments); if(!$return) die(@mysql_error()); } } $db = new SQL(); $query = $db->query("SELECT * FROM this_table WHERE my_variable='1'"); $fetch = $db->fetch_array($query); print_r($fetch); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 68.54.85.50 ---- Manual Page -- http://www.php.net/manual/en/ref.mysql.php Edit -- https://master.php.net/note/edit/74505 Del: integrated -- https://master.php.net/note/delete/74505/integrated Del: useless -- https://master.php.net/note/delete/74505/useless Del: bad code -- https://master.php.net/note/delete/74505/bad+code Del: spam -- https://master.php.net/note/delete/74505/spam Del: non-english -- https://master.php.net/note/delete/74505/non-english Del: in docs -- https://master.php.net/note/delete/74505/in+docs Del: other reasons-- https://master.php.net/note/delete/74505 Reject -- https://master.php.net/note/reject/74505 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125399) next »