国产探花免费观看_亚洲丰满少妇自慰呻吟_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 );
}
}


這樣做看起來就只對可移植有用,其它的作用還體會不到
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宿州市| 宁波市| 高邮市| 建昌县| 双牌县| 海伦市| 城市| 健康| 兰考县| 威远县| 武清区| 娄烦县| 崇礼县| 稻城县| 襄城县| 衢州市| 马公市| 宜章县| 连山| 金坛市| 留坝县| 齐河县| 深泽县| 桦南县| 连平县| 遵义市| 布拖县| 潼关县| 台东县| 德令哈市| 霍州市| 拜城县| 那曲县| 瓮安县| 台东市| 云霄县| 电白县| 临高县| 白银市| 嘉善县| 广元市|