GetOne("Select*From`blog_arctype`whereid=$aid");echo$row['id'];将查询获取总数输出" />

首页 > 教程 >

dedecms织梦数据库类使用方法$dsql

2023-03-09教程围观

简介dedecms的数据库操作类,非常实用,在二次开发中尤其重要。引入common.inc.php文件require_once(dirname(__FILE__)."/include/common.inc.php");获取一条记录的内容$row=$dsql->GetOne("Select*From`blog_arctype`whereid=$aid");echo$row['id'];将查询获取总数输出

  
dedecms的数据库操作类,非常实用,在二次开发中尤其重要。
 
引入common.inc.php文件
 
require_once (dirname(__FILE__) . "/include/common.inc.php");
 
 
获取一条记录的内容
 
$row = $dsql->GetOne("Select * From `blog_arctype` where id = $aid");
echo $row['id'];
 
将查询获取总数输出
 
$row = $dsql->GetOne("select count(*) as dd where typeid = $typeid");
echo $row['dd'];//输出总数
 
 
将查询的若干条记录输出
 
$sql = "Select * from blog_*";
$dsql->SetQuery($sql);//将SQL查询语句格式化
$dsql->Execute();//执行SQL操作
//通过循环输出执行查询中的结果
while($row = $dsql->GetArray()){
echo $row['id'];
echo $row[' '];
}
//或者采取这种方式输出内容
  
  
while($row = $dsql->Get ()){
echo $row->id;
echo $row-> ;
}
 
将查询的若干条记录输出
 
$dsql->SetQuery("Select id,typename From `blog_arctype` where reid=0 And channeltype=1 And ishidden=0 And ispart<>2 order by sortrank");
$dsql->Execute();
while($row=$dsql->Get ())
{
    $channellist .= "<a href='wap.php?action=list&id={$row->id}'>{$row->typename}</a> ";
        echo $row->id;
}
 
 
插入一条记录
 
$sql = "
INSERT INTO `blog_member_f `(mid, ,url, type,imgurl,imgwidth,imgheight)
VALUES(".$cfg_ml->M_ID.",'$ ','$url','$ type','$imgurl','$imgwidth','$imgheight');";//插入记录数据库
$dsql->ExecuteNoneQuery($sql);//执行SQL操作
$gid = $dsql->GetLastID();//获取刚刚插入的id
 
删除一条记录
 
$sql = "Delete From blog_member_f where aid='$aid' And mid='".$cfg_ml->M_ID."';";
$dsql->SetQuery($sql);
$dsql->ExecNoneQuery();
//或者使用简化模式
$dsql->ExecNoneQuery("Delete From blog_member_f where aid='$aid' And mid='".$cfg_ml->M_ID."';");
 
 
更新一条记录
 
$upquery = "
Update blog_member_f set

下载链接:网站源码/小程序源码/网站模板下载

Tags: 织梦 数据库 使用方法 dsql