织梦dedecms怎么写增删改查

wdzsjl 1个月前 (10-10) 阅读数 13 #ZBlog

数据库查询

<?php       require_once (dirname(__FILE__) . "/include/common.inc.php");  //引用数据库连接文件       if($dsql->IsTable(&#39;dede_test&#39;)){           //如果存在dede_test表           //-------------------           //|    查询一条记录 |           //|    GetOne()     |           //-------------------           //        ↓           $row = $dsql->GetOne("SELECT * FROM dede_test WHERE id = 3");           print_r($row);          $sql = "SELECT * FROM dede_test";             $dsql->Execute(&#39;me&#39;,$sql);             while($arr = $dsql->GetArray(&#39;me&#39;))             {                 echo "id = {$arr[&#39;id&#39;]} ,name = {$arr[&#39;name&#39;]}<br />";             }       } ?>

删除

<?php             $id = 1 ;             if($id>0){                 $sql = "DELETE FROM dede_test WHERE id=&#39;$id&#39;";                 $dsql->ExecuteNoneQuery($sql);                 ShowMsg("成功删除一条记录内容!","true.php");  //执行成功后跳转到true.php页面                 exit();               }else{                  ShowMsg("参数不对!","text.php");  //跳转到text.php页面                 exit();               } ?>

修改

<?php             $sql="UPDATE dede_test SET name=&#39;$name&#39;,one=&#39;$one&#39;,two=&#39;$two&#39;  WHERE ID = &#39;$id&#39;";             $dsql->ExecuteNoneQuery($sql);             $lastInsertID = $dsql->GetLastID();             ShowMsg("成功修改一条记录内容!","true.php");  //操作成功跳转到true.php             exit();  ?>

 

wx.jpg ywfw.jpg
热门