您好,欢迎访问一九零五行业门户网

destoon二次开发常用数据库操作_PHP教程

destoon在初始化系统后系统会自动连接数据库,并将数据库操作对象保存在$db。对于数据库操作方法请参考include/db_mysql.class.php函数原型,下面对常用数据库操作举例说明。
1、执行sql语句
$db->query(insert into `{$dt_pre}table` (`xxx`) values ('yyy'));
$db->query(update `{$dt_pre}table` set `xxx`='yyy' where `zzz`=1);
$db->query(delete from `{$dt_pre}table` where `zzz`=1);
2、读取多条信息
$a = array();$result = $db->query(select * from `{$dt_pre}table` where `xxx`='yyy' order by `zzz` desc limit 0,10);while($r = $db->fetch_array($result)) { $a[] = $r;}print_r($a);
3、读取单条信息
$a = $db->get_one(select * from `{$dt_pre}table` where `xxx`='yyy');print_r($a);
4、计算总数
$a = $db->get_one(select count(*) as num from `{$dt_pre}table` where `xxx`='yyy');echo $a['num'];
系统的表前缀可以使用变量$dt_pre(一般在语句中使用)或者$db->pre(一般在函数中使用)。
如果在函数中使用数据库操作,需要先进行global $db;
http://www.bkjia.com/phpjc/825480.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/825480.htmltecharticledestoon在初始化系统后系统会自动连接数据库,并将数据库操作对象保存在$db。对于数据库操作方法请参考include/db_mysql.class.php函数原型,下...
其它类似信息

推荐信息