色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

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

復制代碼 代碼如下:
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 );
}
}

這樣做看起來就只對可移植有用,其它的作用還體會不到

php技術php中mysql模塊部分功能的簡單封裝,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 怀化市| 鄂尔多斯市| 原阳县| 长白| 广元市| 清丰县| 庄浪县| 汝州市| 梨树县| 云浮市| 香河县| 五莲县| 名山县| 若尔盖县| 南汇区| 嘉善县| 龙山县| 康定县| 开江县| 叙永县| 怀来县| 拉萨市| 江西省| 普兰店市| 板桥市| 夏邑县| 焉耆| 抚宁县| 东乡族自治县| 称多县| 浮梁县| 吴桥县| 紫金县| 玉田县| 大连市| 武强县| 葵青区| 石楼县| 北川| 泾阳县| 昭通市|