- 新增db.class.php调用 使用全部方法,需要以对象方式调用
https://www.kancloud.cn/logoove/we7/678561
require_once(DEDEINC.'/Db.class.php');
$db = new Db($GLOBALS['cfg_dbhost'],$GLOBALS['cfg_dbuser'],$GLOBALS['cfg_dbpwd'],'3306',$GLOBALS['cfg_dbname'],$GLOBALS['cfg_dbprefix']);
- 单条数据
global $dsql;
$row = $dsql->GetOne("SELECT * FROM hx_arctype WHERE id= $id");
新写法
global $db;
$row =$db->get('arctype',array('id'=>$id));
- 多条数据
$sql = "Select * from #@__arctype";
$dsql->SetQuery($sql);
$dsql->Execute();
while($row = $dsql->GetArray()){
$row1[]= ['id'=>$row['id'],'typename'=>$row['typename']];
}
$n= $dsql->GetTotalRow(); 总记录数
新写法
global $db;
$db->getall('arctype');
- 插入删除修改
$sql = "insert into hx_arctype (typename) VALUES ('测试')";
$dsql->ExecNoneQuery($sql);
$id = $dsql->GetLastID();插入id
$sql = "delete from hx_arctype where id=12";
$dsql->ExecNoneQuery($sql);
$sql = "update hx_arctype set typename='12' where id=13";
$dsql->ExecNoneQuery($sql);
新写法
global $db;
$db->insert('demo',array());
$id = $db->insertid();插入id
$db->update('demo',['num +='=>1],['id'=>1]);
$db->delete('demo',['id'=>1]);
$db->delete('demo', "id IN ('".implode("','", $deleteid)."')");//多选删除
作者:Yoby 创建时间:2020-07-23 22:24
更新时间:2024-12-05 13:26
更新时间:2024-12-05 13:26