色尼玛亚洲综合影院,亚洲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模塊部分功能的簡單封裝,轉載需保留來源!

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

主站蜘蛛池模板: 周至县| 长垣县| 张家口市| 平潭县| 恩施市| 灵武市| 大石桥市| 城固县| 勐海县| 安徽省| 桓台县| 山阴县| 古交市| 宁远县| 黄浦区| 左贡县| 安吉县| 青龙| 肇州县| 宁远县| 宜兰县| 赣州市| 易门县| 炉霍县| 尼勒克县| 新郑市| 长春市| 拜泉县| 扎赉特旗| 大庆市| 门头沟区| 独山县| 类乌齐县| 桃园县| 万安县| 浦北县| 黄山市| 县级市| 江都市| 嘉荫县| 屯留县|