Home Backend Development PHP Tutorial destoon二次开发常用数据库操作_PHP

destoon二次开发常用数据库操作_PHP

Jun 01, 2016 am 11:51 AM
Secondary development Database operations

destoon在初始化系统后系统会自动连接数据库,并将数据库操作对象保存在$db。对于数据库操作方法请参考include/db_mysql.class.php函数原型,下面对常用数据库操作举例说明。

1、执行SQL语句

$db->query("INSERT INTO `{$DT_PRE}table` (`xxx`) VALUES ('yyy')");

Copy after login
$db->query("UPDATE `{$DT_PRE}table` SET `xxx`='yyy' WHERE `zzz`=1");

Copy after login
$db->query("DELETE FROM `{$DT_PRE}table` WHERE `zzz`=1");

Copy after login


2、读取多条信息

$A = array();
$result = $db->query("SELECT * FROM `{$DT_PRE}table` WHERE `xxx`='yyy' ORDER BY `zzz` DESC LIMIT 0,10");
while($r = $db->fetch_array($result)) {
  $A[] = $r;
}
print_r($A);

Copy after login

3、读取单条信息

$A = $db->get_one("SELECT * FROM `{$DT_PRE}table` WHERE `xxx`='yyy'");
print_r($A);

Copy after login

4、计算总数

$A = $db->get_one("SELECT COUNT(*) AS num FROM `{$DT_PRE}table` WHERE `xxx`='yyy'");
echo $A['num'];

Copy after login

系统的表前缀可以使用变量$DT_PRE(一般在语句中使用)或者$db->pre(一般在函数中使用)。
如果在函数中使用数据库操作,需要先进行global $db;

Statement of this Website
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)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Simple and easy-to-understand Java Hikvision SDK secondary development guide Simple and easy-to-understand Java Hikvision SDK secondary development guide Sep 06, 2023 pm 02:01 PM

Simple and easy-to-understand Java Hikvision SDK secondary development guide Introduction: With the development of camera surveillance technology, Hikvision has become one of the world's leading security solution providers. The SDK (software development kit) it provides is Developers provide a wealth of functions and interfaces for secondary development and customized development. This article will introduce how to use Java language for secondary development of Hikvision SDK, and provide some code examples to help readers better understand and apply. 1. Environment preparation First, before carrying out secondary development of Hikvision SDK

Baidu Intelligent Cloud Qianfan large model platform has been upgraded again: 5 large models and 55 new tool components have been released! Baidu Intelligent Cloud Qianfan large model platform has been upgraded again: 5 large models and 55 new tool components have been released! Mar 22, 2024 am 08:10 AM

Serving 80,000 enterprise users, it has helped users fine-tune 13,000 large models and helped users develop 160,000 large model applications. Since December 2023, the daily API calls of Baidu Smart Cloud Qianfan Large Model Platform have increased by 97% month-on-month. ..From the "pioneer" of the domestic large model platform a year ago to today's large model "super factory", Baidu Intelligent Cloud Qianfan large model platform firmly occupies a leading position in the domestic large model market, but its pace is slow. Didn't stop. On March 21, Baidu Intelligent Cloud held a Qianfan product launch conference in Beijing Shougang Park. Baidu Intelligent Cloud announced during the conference: 1. Joining hands with Beijing Shijingshan District to build the country's first Baidu Intelligent Cloud Qianfan large-scale model industrial innovation base to help Promote the take-off of regional industries; 2. Satisfy the “valency” of enterprises

How to use PHP scripts to perform database operations in Linux environment How to use PHP scripts to perform database operations in Linux environment Oct 05, 2023 pm 03:48 PM

How to use PHP to perform database operations in a Linux environment. In modern web applications, the database is an essential component. PHP is a popular server-side scripting language that can interact with various databases. This article will introduce how to use PHP scripts for database operations in a Linux environment and provide some specific code examples. Step 1: Install the Necessary Software and Dependencies Before starting, we need to ensure that PHP and related dependencies are installed in the Linux environment. usually

TensorFlow deep learning framework model inference pipeline for portrait cutout inference TensorFlow deep learning framework model inference pipeline for portrait cutout inference Mar 26, 2024 pm 01:00 PM

Overview In order to enable ModelScope users to quickly and conveniently use various models provided by the platform, a set of fully functional Python libraries are provided, which includes the implementation of ModelScope official models, as well as the necessary tools for using these models for inference, finetune and other tasks. Code related to data pre-processing, post-processing, effect evaluation and other functions, while also providing a simple and easy-to-use API and rich usage examples. By calling the library, users can complete tasks such as model reasoning, training, and evaluation by writing just a few lines of code. They can also quickly perform secondary development on this basis to realize their own innovative ideas. The algorithm model currently provided by the library is:

How to use Pagoda Panel for MySQL management How to use Pagoda Panel for MySQL management Jun 21, 2023 am 09:44 AM

Pagoda Panel is a powerful panel software that can help us quickly deploy, manage and monitor servers, especially small businesses or individual users who often need to build websites, database management and server maintenance. Among these tasks, MySQL database management is an important job in many cases. So how to use the Pagoda panel for MySQL management? Next, we will introduce it step by step. Step 1: Install Pagoda Panel. Before starting to use Pagoda Panel for MySQL management, you first need to install Pagoda Panel.

Key elements to improve secondary development skills of Java Hikvision SDK Key elements to improve secondary development skills of Java Hikvision SDK Sep 06, 2023 pm 01:42 PM

Summary of key elements to improve Java Hikvision SDK secondary development skills: With the rapid development of the Internet of Things, video surveillance systems are increasingly used in the security field. As the most important component of the video surveillance system, Hikvision’s SDK plays an important role in the secondary development process. This article will introduce the basic usage of Hikvision SDK and provide some key elements and code examples to help readers improve their Java Hikvision SDK secondary development skills. 1. Understand the basic overview of Hikvision SDK

What does WordPress secondary development mean? What does WordPress secondary development mean? Apr 16, 2024 am 12:09 AM

WordPress secondary development allows developers to customize and extend WordPress functionality, creating additional features, themes, and plugins that meet specific needs. Through secondary development, developers can customize WordPress, extend its core functionality, increase its flexibility, and easily expand its scalability as the website and business grow.

Everyone can become an AI developer! Robin Li brings three major AI development tools Everyone can become an AI developer! Robin Li brings three major AI development tools Apr 18, 2024 pm 03:40 PM

Emerging as the brightest star in the technology field in early 2023, it demonstrates the huge potential of Kai AI technology to transform the economy and society. After more than a year of technological breakthroughs and market verification, entering 2024, the huge value of large models has been recognized by mainstream countries, and mainstream technology companies have made plans. Countries such as the United States and China are in the future of leading the development of the large model industry. Among domestic technology companies, Baidu was the first to release Wenxin's large model and has achieved extraordinary results. At the Create2024 Baidu AI Developer Conference held today, Robin Li, founder, chairman and CEO of Baidu, revealed in his keynote speech that the number of Wenxin Yiyan users exceeded 200 million, and the Wenxin Big Model has become China's leading and most widely used model. Extensive AI base models. At the same time, Robin Li

See all articles