空界的废墟 發表於 2024-3-19 00:00:00

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

<span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>dedecms的数据库操作类,非常实用,在二次开发中尤其重要,这个数据库操作类说明算是奉献给大家的小礼物了。</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'> </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>引入common.inc.php文件</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode13" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        require_once (dirname(__FILE__) . "/include/common.inc.php");</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>获取一条记录的内容</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode14" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $row = $dsql-&gt;GetOne("Select * From dede_* where id = $aid");<br>
        echo $row['id'];</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>将查询获取总数输出</strong><br><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode15" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $row = $dsql-&gt;GetOne("select count(*) as dd where typeid = $typeid");<br>
        echo $row['dd'];//输出总数</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>将查询的若干条记录输出</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode16" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $sql = "Select * from dede_*";<br>
        $dsql-&gt;SetQuery($sql);//将SQL查询语句格式化<br>
        $dsql-&gt;Execute();//执行SQL操作<br>
        //通过循环输出执行查询中的结果<br>
        while($row = $dsql-&gt;GetArray()){<br>
        echo $row['id'];<br>
        echo $row['title'];<br>
        }<br>
        //或者采取这种方式输出内容<br><br>
        while($row = $dsql-&gt;GetObject()){<br>
        echo $row-&gt;id;<br>
        echo $row-&gt;Title;<br>
        }</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>将查询的若干条记录输出dedecms5</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode17" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $dsql-&gt;SetQuery("Select id,typename From `dede_arctype` where reid=0 And channeltype=1 And ishidden=0 And ispart&lt;&gt;2 order by sortrank");<br>
        $dsql-&gt;Execute();<br>
        while($row=$dsql-&gt;GetObject())<br>
        {<br>
        $channellist .= "&lt;a href='wap.php?action=list&amp;id={$row-&gt;id}'&gt;{$row-&gt;typename}&lt;/a&gt; ";<br>
        echo $row-&gt;id;<br>
        }</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>插入一条记录</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode18" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $sql = "<br>
        INSERT INTO `dede_member_flink`(mid,title,url,linktype,imgurl,imgwidth,imgheight) <br>
        VALUES(".$cfg_ml-&gt;M_ID.",'$title','$url','$linktype','$imgurl','$imgwidth','$imgheight');";//插入记录数据库<br>
        $dsql-&gt;SetQuery($sql);//格式化查询语句<br>
        $dsql-&gt;ExecNoneQuery();//执行SQL操作</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>经实践证明,上面的语句不能正常插入数据库,下面是正确的语句</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode19" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $sql = "<br>
        INSERT INTO `dede_member_flink`(mid,title,url,linktype,imgurl,imgwidth,imgheight) <br>
        VALUES(".$cfg_ml-&gt;M_ID.",'$title','$url','$linktype','$imgurl','$imgwidth','$imgheight');";//插入记录数据库<br>
        $dsql-&gt;ExecuteNoneQuery($sql);//执行SQL操作<br>
        $gid = $dsql-&gt;GetLastID();//获取刚刚插入的id</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>删除一条记录</strong><br><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode20" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $sql = "Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml-&gt;M_ID."';";<br>
        $dsql-&gt;SetQuery($sql);<br>
        $dsql-&gt;ExecNoneQuery();<br>
        //或者使用简化模式<br>
        $dsql-&gt;ExecNoneQuery("Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml-&gt;M_ID."';");</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>更新一条记录</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode21" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $upquery = "<br>
        Update dede_member_flink set <br>
        title='$title',url='$url',linktype='$linktype',<br>
        imgurl='$imgurl',imgwidth='$imgwidth',imgheight='$imgheight'<br>
        where aid='$aid' And mid='".$cfg_ml-&gt;M_ID."';<br>
        ";<br>
        $rs = $dsql-&gt;ExecuteNoneQuery($upquery);</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>判断获取数据库内容的常用方法</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode22" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $row = $dsql-&gt;GetOne("Select * From dede_moneycard_type where tid={$pid}");<br>
        if(!is_array($row)){<br>
        echo "失败";<br>
        exit();<br>
        } <br><br>
        /////////////////////////////<br>
        $upquery = " Update dede_member_flink set <br>
        title='$title',url='$url',linktype='$linktype',<br>
        imgurl='$imgurl',imgwidth='$imgwidth',imgheight='$imgheight'<br>
        where aid='$aid' And mid='".$cfg_ml-&gt;M_ID."';<br>
        ";<br>
        $rs = $dsql-&gt;ExecuteNoneQuery($upquery);<br>
        if($rs){<br>
        echo "成功";<br>
        }else{<br>
        echo "失败";<br>
        }</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>获取总数</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode23" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $dsql = new DedeSql(false);<br>
        $dsql-&gt;SetQuery("Select * from `dede_admin` where userid='$userid' Or uname='$uname'");<br>
        $dsql-&gt;Execute();<br>
        $ns = $dsql-&gt;GetTotalRow();</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>关闭数据库</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode24" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        $dsql-&gt;Close();</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>实例</strong><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode25" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        &lt;?php<br>
        /*<br>
        DedeCms 数据库使用实例说明<br>
        */<br>
        require_once dirname(__FILE__)."pub_db_mysql.php";//引用数据库文件<br><br>
        //确保数据库信息填写正确<br>
        //数据库连接信息<br>
        $cfg_dbhost = 'localhost';<br>
        $cfg_dbname = 'sccms';<br>
        $cfg_dbuser = 'root';<br>
        $cfg_dbpwd = '123456';<br>
        $cfg_dbprefix = 'sc_';<br>
        $cfg_db_language = 'utf8';<br><br>
        //新建一个数据库操作类<br>
        $dsql = new ScSql(false);<br><br>
        ////////////////////////////////获取一条记录的内容///////////////////////////////<br>
        //下面是获取一条记录使用实例<br>
        $row = $dsql-&gt;GetOne("Select * From dede_* where id = $aid");<br>
        //获取数据内容保存在数组$row中,通过下标可以将其调用出来<br>
        echo $row['id'];<br>
        //下面是循环调用记录<br>
        ///////////////////////////////////////////////////////////////////////////////<br><br><br>
        //////////////////////////////将查询获取总数输出/////////////////////////////<br>
        //获取一个查询记录总数<br>
        $row = $dsql-&gt;GetOne("select count(*) as dd where typeid = $typeid");<br>
        echo $row['dd'];//输出总数<br>
        ///////////////////////////////////////////////////////////////////////////////<br><br><br>
        //////////////////////////////将查询的若干条记录输出//////////////////////////////////<br>
        $sql = "Select * from dede_*";<br>
        $dsql-&gt;SetQuery($sql);//将SQL查询语句格式化<br>
        $dsql-&gt;Execute();//执行SQL操作<br>
        //通过循环输出执行查询中的结果<br>
        while($row = $dsql-&gt;GetArray()){<br>
        echo $row['id'];<br>
        echo $row['title'];<br>
        }<br>
        //或者采取这种方式输出内容<br><br><br>
        while($row = $dsql-&gt;GetObject()){<br>
        echo $row-&gt;id;<br>
        echo $row-&gt;Title;<br>
        }<br>
        ///////////////////////////////////////////////////////////////////////////////<br><br>
        //////////////////////////////插入一条记录///////////////////////////////<br>
        $sql = "<br>
        INSERT INTO `dede_member_flink`(mid,title,url,linktype,imgurl,imgwidth,imgheight) <br>
        VALUES(".$cfg_ml-&gt;M_ID.",'$title','$url','$linktype','$imgurl','$imgwidth','$imgheight');";//插入记录数据库<br>
        $dsql-&gt;SetQuery($sql);//格式化查询语句<br>
        $dsql-&gt;ExecNoneQuery();//执行SQL操作<br>
        ///////////////////////////////////////////////////////////////////////////////<br><br>
        /////////////////////////////////////删除一条记录///////////////////////////<br>
        $sql = "Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml-&gt;M_ID."';";<br>
        $dsql-&gt;SetQuery($sql);<br>
        $dsql-&gt;ExecNoneQuery();<br>
        //或者使用简化模式<br>
        $dsql-&gt;ExecNoneQuery("Delete From dede_member_flink where aid='$aid' And mid='".$cfg_ml-&gt;M_ID."';");<br>
        ///////////////////////////////////////////////////////////////////////////////<br><br>
        //////////////////////////////////////更新一条记录//////////////////////////<br>
        $upquery = "<br>
        Update dede_member_flink set <br>
        title='$title',url='$url',linktype='$linktype',<br>
        imgurl='$imgurl',imgwidth='$imgwidth',imgheight='$imgheight'<br>
        where aid='$aid' And mid='".$cfg_ml-&gt;M_ID."';<br>
        ";<br>
        $rs = $dsql-&gt;ExecuteNoneQuery($upquery);<br><br>
        ///////////////////////////////////////////////////////////////////////////////<br><br>
        ////////////////////////////////判断获取数据库内容的常用方法///////////////////<br>
        $row = $dsql-&gt;GetOne("Select * From dede_moneycard_type where tid={$pid}");<br>
        if(!is_array($row)){<br>
        echo "失败";<br>
        exit();<br>
        } <br><br>
        /////////////////////////////<br>
        $upquery = " Update dede_member_flink set <br>
        title='$title',url='$url',linktype='$linktype',<br>
        imgurl='$imgurl',imgwidth='$imgwidth',imgheight='$imgheight'<br>
        where aid='$aid' And mid='".$cfg_ml-&gt;M_ID."';<br>
        ";<br>
        $rs = $dsql-&gt;ExecuteNoneQuery($upquery);<br>
        if($rs){<br>
        echo "成功";<br>
        }else{<br>
        echo "失败";<br>
        }<br>
        //////////////////////////////////获取总数//////////////////////////////////<br>
        $dsql = new DedeSql(false);<br>
        $dsql-&gt;SetQuery("Select * from `dede_admin` where userid='$userid' Or uname='$uname'");<br>
        $dsql-&gt;Execute();<br>
        $ns = $dsql-&gt;GetTotalRow();<br>
        ////////////////////////////////关闭数据库///////////////////////////////////<br>
        $dsql-&gt;Close();<br>
        ///////////////////////////////////////////////////////////////////////////////<br>
        ?&gt;</div>
頁: [1]
查看完整版本: 织梦dedecms数据库类$dsql使用方法步骤