做dedecms的二次开发中间需要很多用sql语句来根据需要整合新的功能和页面,先将内容付下,搜外首发:)
列表显示用法
$dsql->SetQuery("SELECT * FROM dede_payment WHERE enabled='1' ORDER BY rank ASC");
$dsql->Execute();
$i = 0 ;
while($row = $dsql->GetArray())
{
$row['disabled'] = ($row['id'] == 5) && ($cfg_ml->M_Money < $priceCount) ? ' disabled="disabled"' : '';
$shops_paymentarr[] = $row;
$i++;
}
此方法在无法直接用在member目录下的htm模板内,下面的方法比较适用所有能适用php语法的环境
$dsql->Execute('fl',"SELECT a.id,a.title,a.litpic,b.price,b.jdxj from hw_archives a left join hw_addonshop30 b on a.id=b.aid where $addsql limit $offset,$pagesize");
while($rowa = $dsql->GetArray('fl'))
{
}
DELETE删除用法
//不能删除id为1的创建人帐号,不能删除自己
$rs = $dsql->ExecuteNoneQuery2("DELETE FROM `dede_admin` WHERE id='$id' AND id<>1 AND id<>'".$cuserLogin->getUserID()."' ");
select查询用法
$sql = "select *
FROM `hw_shops_orders` where gys='$mid' $addsql and state='0'";
$row = $dsql->GetOne($sql);
UPDATE更新用法
$query = "UPDATE `dede_member` SET uname='$uname',email='$email'$pwdm WHERE mid='$id'";
$dsql->ExecuteNoneQuery($query);
ShowMsg("成功更改一个帐户!", "sys_admin_user.php");
exit();
插入新纪录的方法
$query = "
INSERT INTO dede_myad(clsid,typeid,tagname,adname,timeset,starttime,endtime,normbody,expbody)
VALUES('$clsid','$typeid','$tagname','$adname','$timeset','$starttime','$endtime','$normbody','$expbody');
";
$dsql->ExecuteNoneQuery($query);
ShowMsg("成功增加一个广告!","ad_main.php");
exit();
此文由 网站目录_网站网址收录与提交入口 编辑,未经允许不得转载!: