POST TIME:2017-11-13 00:42
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'];//輸出總數(shù)
$sql = "Select * from dede_*";$dsql->SetQuery($sql);//將SQL查詢語句格式化$dsql->Execute();//執(zhí)行SQL操作//通過循環(huán)輸出執(zhí)行查詢中的結(jié)果while($row = $dsql->GetArray()){echo $row['id'];echo $row['title'];}//或者采取這種方式輸出內(nèi)容while($row = $dsql->GetObject()){echo $row->id;echo $row->Title;}將查詢的若干條記錄輸出dedecms5$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 .= "<a href='wap.php?action=list&id={$row->id}'>{$row->typename}</a> ";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');";//插入記錄數(shù)據(jù)庫$dsql->SetQuery($sql);//格式化查詢語句$dsql->ExecNoneQuery();//執(zhí)行SQL操作
$sql = "INSERT INTO `dede_member_flink`(mid,title,url,linktype,imgurl,imgwidth,imgheight)VALUES(".$cfg_ml->M_ID.",'$title','$url','$linktype','$imgurl','$imgwidth','$imgheight');";//插入記錄數(shù)據(jù)庫$dsql->ExecuteNoneQuery($sql);//執(zhí)行SQL操作$gid = $dsql->GetLastID();//獲取剛剛插入的id
$sql = "Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml->M_ID."';";$dsql->SetQuery($sql);$dsql->ExecNoneQuery();//或者使用簡化模式$dsql->ExecNoneQuery("Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml->M_ID."';");
$upquery = "Update dede_member_flink settitle='$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 settitle='$title',url='$url',linktype='$linktype',imgurl='$imgurl',imgwidth='$imgwidth',imgheight='$imgheight'where aid='$aid' And mid='".$cfg_ml->M_ID."';";$rs = $dsql->ExecuteNoneQuery($upquery);if($rs){echo "成功";}else{echo "失敗";}
$dsql = new DedeSql(false);$dsql->SetQuery("Select * from `dede_admin` where userid='$userid' Or uname='$uname'");$dsql->Execute();$ns = $dsql->GetTotalRow();
$dsql->Close();
<?php/*DedeCms 數(shù)據(jù)庫使用實(shí)例說明*/require_once dirname(__FILE__)."pub_db_mysql.php";//引用數(shù)據(jù)庫文件//確保數(shù)據(jù)庫信息填寫正確//數(shù)據(jù)庫連接信息$cfg_dbhost = 'localhost';$cfg_dbname = 'sccms';$cfg_dbuser = 'root';$cfg_dbpwd = '123456';$cfg_dbprefix = 'sc_';$cfg_db_language = 'utf8';//新建一個數(shù)據(jù)庫操作類$dsql = new ScSql(false);////////////////////////////////獲取一條記錄的內(nèi)容/////////////////////////////////下面是獲取一條記錄使用實(shí)例$row = $dsql->GetOne("Select * From dede_* where id = $aid");//獲取數(shù)據(jù)內(nèi)容保存在數(shù)組$row中,通過下標(biāo)可以將其調(diào)用出來echo $row['id'];//下面是循環(huán)調(diào)用記錄/////////////////////////////////////////////////////////////////////////////////////////////////////////////將查詢獲取總數(shù)輸出///////////////////////////////獲取一個查詢記錄總數(shù)$row = $dsql->GetOne("select count(*) as dd where typeid = $typeid");echo $row['dd'];//輸出總數(shù)/////////////////////////////////////////////////////////////////////////////////////////////////////////////將查詢的若干條記錄輸出//////////////////////////////////$sql = "Select * from dede_*";$dsql->SetQuery($sql);//將SQL查詢語句格式化$dsql->Execute();//執(zhí)行SQL操作//通過循環(huán)輸出執(zhí)行查詢中的結(jié)果while($row = $dsql->GetArray()){echo $row['id'];echo $row['title'];}//或者采取這種方式輸出內(nèi)容while($row = $dsql->GetObject()){echo $row->id;echo $row->Title;}/////////////////////////////////////////////////////////////////////////////////////////////////////////////插入一條記錄///////////////////////////////$sql = "INSERT INTO `dede_member_flink`(mid,title,url,linktype,imgurl,imgwidth,imgheight)VALUES(".$cfg_ml->M_ID.",'$title','$url','$linktype','$imgurl','$imgwidth','$imgheight');";//插入記錄數(shù)據(jù)庫$dsql->SetQuery($sql);//格式化查詢語句$dsql->ExecNoneQuery();//執(zhí)行SQL操作////////////////////////////////////////////////////////////////////////////////////////////////////////////////////刪除一條記錄///////////////////////////$sql = "Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml->M_ID."';";$dsql->SetQuery($sql);$dsql->ExecNoneQuery();//或者使用簡化模式$dsql->ExecNoneQuery("Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml->M_ID."';");/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////更新一條記錄//////////////////////////$upquery = "Update dede_member_flink settitle='$title',url='$url',linktype='$linktype',imgurl='$imgurl',imgwidth='$imgwidth',imgheight='$imgheight'where aid='$aid' And mid='".$cfg_ml->M_ID."';";$rs = $dsql->ExecuteNoneQuery($upquery);///////////////////////////////////////////////////////////////////////////////////////////////////////////////判斷獲取數(shù)據(jù)庫內(nèi)容的常用方法///////////////////$row = $dsql->GetOne("Select * From dede_moneycard_type where tid={$pid}");if(!is_array($row)){echo "失敗";exit();}/////////////////////////////$upquery = " Update dede_member_flink settitle='$title',url='$url',linktype='$linktype',imgurl='$imgurl',imgwidth='$imgwidth',imgheight='$imgheight'where aid='$aid' And mid='".$cfg_ml->M_ID."';";$rs = $dsql->ExecuteNoneQuery($upquery);if($rs){echo "成功";}else{echo "失敗";}//////////////////////////////////獲取總數(shù)//////////////////////////////////$dsql = new DedeSql(false);$dsql->SetQuery("Select * from `dede_admin` where userid='$userid' Or uname='$uname'");$dsql->Execute();$ns = $dsql->GetTotalRow();////////////////////////////////關(guān)閉數(shù)據(jù)庫///////////////////////////////////$dsql->Close();///////////////////////////////////////////////////////////////////////////////?>