require_once (dirname(__FILE__) . "/include/common.inc.PHP");
$row = $dsql->GetOne("Select * From dede_* where id = $aid");
echo $row['id'];
$row = $dsql->GetOne("select count(*) as dd where typeid = $typeid");
echo $row['dd'];//输出总数
$sql = "Select * from dede_*";
while($row = $dsql->GetArray()){
echo $row['id'];
echo $row['title'];
}
while($row = $dsql->GetObject()){
echo $row->id;
echo $row->Title;
}
$dsql->SetQuery("Select id,typename From `dede_arctype` where reid=0 And channeltype=1 And ishidden=0 And ispart<>2 order by sortrank");
$dsql->Execute();
while($row=$dsql->GetObject())
{
$channellist .= "
原文链接:https://www.f2er.com/dedecms/451599.html
echo $row->id;
}
插入一条记录
$sql = "
INSERT INTO `dede_member_flink`(mid,title,url,linktype,imgurl,imgwidth,imgheight)
VALUES(".$cfg_ml->M_ID.",'$title','$url','$linktype','$imgurl','$imgwidth','$imgheight');";//插入记录数据库
经实践证明,上面的语句不能正常插入数据库,下面是正确的语句
$sql = "
INSERT INTO `dede_member_flink`(mid,'$imgheight');";//插入记录数据库
删除一条记录
$sql = "Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml->M_ID."';";
$dsql->ExecNoneQuery();
//或者使用简化模式
$dsql->ExecNoneQuery("Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml->M_ID."';");
更新一条记录
$upquery = "
Update dede_member_flink set
title='$title',url='$url',linktype='$linktype',
imgurl='$imgurl',imgwidth='$imgwidth',imgheight='$imgheight'
where aid='$aid' And mid='".$cfg_ml->M_ID."';
";
$rs = $dsql->ExecuteNoneQuery($upquery);
$row = $dsql->GetOne("Select * From dede_moneycard_type where tid={$pid}");
if(!is_array($row)){
echo "失败";
exit();
}
/////////////////////////////
$upquery = " Update dede_member_flink set
title='$title',imgheight='$imgheight'
where aid='$aid' And mid='".$cfg_ml->M_ID."';
";
$rs = $dsql->ExecuteNoneQuery($upquery);
if($rs){
echo "成功";
}else{
echo "失败";
}
获取总数
$dsql->SetQuery("Select * from `dede_admin` where userid='$userid' Or uname='$uname'");
$dsql->Execute();
$ns = $dsql->GetTotalRow();
$dsql->Close();
实例
/*
*/
//确保数据库信息填写正确
//数据库连接信息
$cfg_dbhost = 'localhost';
$cfg_dbname = 'sccms';
$cfg_dbuser = 'root';
$cfg_dbpwd = '123456';
$cfg_dbprefix = 'sc_';
$cfg_db_language = 'utf8';
//新建一个数据库操作类
//下面是获取一条记录使用实例
$row = $dsql->GetOne("Select * From dede_* where id = $aid");
echo $row['id'];
//下面是循环调用记录
///////////////////////////////////////////////////////////////////////////////
$row = $dsql->GetOne("select count(*) as dd where typeid = $typeid");
echo $row['dd'];//输出总数
///////////////////////////////////////////////////////////////////////////////
$sql = "Select * from dede_*";
while($row = $dsql->GetArray()){
echo $row['id'];
echo $row['title'];
}
while($row = $dsql->GetObject()){
echo $row->id;
echo $row->Title;
}
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////插入一条记录///////////////////////////////
$sql = "
INSERT INTO `dede_member_flink`(mid,'$imgheight');";//插入记录数据库
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////删除一条记录///////////////////////////
$sql = "Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml->M_ID."';";
$dsql->ExecNoneQuery();
//或者使用简化模式
$dsql->ExecNoneQuery("Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml->M_ID."';");
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////更新一条记录//////////////////////////
$upquery = "
Update dede_member_flink set
title='$title',imgheight='$imgheight'
where aid='$aid' And mid='".$cfg_ml->M_ID."';
";
$rs = $dsql->ExecuteNoneQuery($upquery);
///////////////////////////////////////////////////////////////////////////////
$row = $dsql->GetOne("Select * From dede_moneycard_type where tid={$pid}");
if(!is_array($row)){
echo "失败";
exit();
}
/////////////////////////////
$upquery = " Update dede_member_flink set
title='$title',imgheight='$imgheight'
where aid='$aid' And mid='".$cfg_ml->M_ID."';
";
$rs = $dsql->ExecuteNoneQuery($upquery);
if($rs){
echo "成功";
}else{
echo "失败";
}
//////////////////////////////////获取总数//////////////////////////////////
$dsql->SetQuery("Select * from `dede_admin` where userid='$userid' Or uname='$uname'");
$dsql->Execute();
$ns = $dsql->GetTotalRow();
$dsql->Close();
///////////////////////////////////////////////////////////////////////////////
?>