国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php中mysql模塊部分功能的簡單封裝

2024-05-04 23:16:47
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:


class mysql
{
private $db; // datebase connect
private $result; // mysql result
static private $mysql; // mysql object
private function __construct()
{ // The work before Create an object
$this->db = mysql_connect('localhost','root','');
mysql_select_db('hello', $this->db );
}
public static function getObject()
{ //if have a object,return that object,Not create
if(! self::$mysql instanceof self)
self::$mysql = new self;
return self::$mysql;
}
public function query($sql)
{
$this->result = mysql_query($sql, $this->db);
return $this->result;
}
public function fetch()
{
if( isset($this->result ) )
return mysql_fetch_assoc( $this->result );
}
public function error()
{
return 'error:'.mysql_error();
}
public function num() // for sql select result
{
return mysql_num_rows( $this->result );
}
public function close()
{ // return true or false
return mysql_close( $this->db );
}
}


這樣做看起來就只對可移植有用,其它的作用還體會不到
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宁武县| 蒙自县| 珠海市| 宁乡县| 任丘市| 锡林郭勒盟| 青浦区| 金塔县| 盈江县| 樟树市| 福州市| 陕西省| 陆良县| 米易县| 中西区| 广丰县| 来宾市| 镇坪县| 双辽市| 济宁市| 香河县| 布尔津县| 嵊泗县| 建德市| 晋州市| 广安市| 耿马| 汶上县| 曲靖市| 晋江市| 璧山县| 涞源县| 油尖旺区| 洮南市| 澄城县| 栖霞市| 灵璧县| 康保县| 祁东县| 得荣县| 新乐市|