您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

简单的数据库链式操作的例子

2025/2/7 3:06:45发布40次查看
host = $host; $this->username = $username; $this->password = $password; $this->dbname = $dbname; $this->dbconnect();}/* 数据库连接*/privatefunctiondbconnect(){ mysql_connect($this->host,$this->username,$this->password); mysql_select_db($this->dbname);}/**执行sql语句***/publicfunctionquery($sql){ $this->sql = $sql; $this->result = mysql_query($this->sql); return$this;}/***$select = false时输出sql语句*/publicfunctionselect($select= true){ $this->select = $select; if($this->select){ return$this->array = $this->result(); }else{ return$this->sql; }}/***结果集*/privatefunctionresult(){ $array = mysql_fetch_array($this->result); return$array;}
}
?> 
使用方法 include “./api/datebase.php”; 
define('db_host_name','localhost'); 
define('db_host_username','root'); 
define('db_host_password','root'); 
define('db_host_db','jciot'); 
$jciot_db = new mysqldb(db_host_name,db_host_username,db_host_password,db_host_db); 
$a = $jciot_db->query('select * from jciot_member')->select(); 
var_dump($a);
?>`
以上就介绍了简单的数据库链式操作的例子,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product