search
HomeCMS TutorialDEDECMSHow to write dedecms: add, delete, modify, check

How to write dedecms: add, delete, modify, check

Jul 19, 2019 am 09:55 AM
dedecmsdatabase

How to write dedecms: add, delete, modify, check

Tips: dedecms common.inc.phpThe code encapsulates the database information and can be imported directly.

Recommended tutorial: dedecms tutorial

##1. Dede database query:

<?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 />";
            }
      }
?>

2. Dede delete data

<?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();  
            }
?>

3. dedecms insert data

<?php
       $sql="INSERT INTO dede_test(name,one,two) VALUES ( &#39;$name&#39;,&#39;$one&#39;,&#39;$two&#39;)";
            $dsql->ExecuteNoneQuery($sql);
            $lastInsertID = $dsql->GetLastID();
            ShowMsg("成功增加一条记录内容!","test.php");
?>

4.dedecms modify data

<?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();

?>


The above is the detailed content of How to write dedecms: add, delete, modify, check. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool