复制代码 代码如下:
class mysql
{
private $db; // dateba 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_lect_db(‘hello’, $this->db );
}
public static function geto立体画教程bject()
{ //if have a object,return that object,not create
if(! lf::$mysql instanceof lf)
lf::$mysql = new lf;
return lf::$mysql;
}
pu宜良一中blic function query($sql)
{
$this->result = mysql_query($sql, $this->db);
return $this->result;
}
public function fetch()
{
if( ist($this->result千里共婵娟什么意思 ) )
return mysql_fetch_assoc( $this->result );
}
public function error()
{
return ‘error:’.mysql_error();
}
public function num() // for sql lect result
{
return mysql_num_rows( $this->result );
}
public function clo()
{ // return true or fal
鬼节习俗return mysql_clo( $this->db );
}
}
这样做看起来就只对可移植有用,其它的作用还体会不到
本文发布于:2023-04-06 11:08:06,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/4262d617df9859a33fee2753a7c8db15.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:php中mysql模块部分功能的简单封装.doc
本文 PDF 下载地址:php中mysql模块部分功能的简单封装.pdf
留言与评论(共有 0 条评论) |