


How to use the database class that comes with Empire CMS_PHP Tutorial
Empire CMS encapsulates a SQL, and the file location is e/class/db_sql.php; using the class library of the program itself can bring convenience and efficiency to our development, and at the same time reduce the number of additional files.
First, make the preparations:
- Create a test directory under the e directory, for example, I created e/trylife/td-test/
- Create a PHP file in the directory 1, for example, I created e/trylife/td/test-db_sql.php
- The code written in the file is as follows:
<?php /*引用文件*/ include("../../class/connect.php"); include("../../class/db_sql.php"); /*建立数据库链接 与 实例化类*/ $link=db_connect(); $empire=new mysqlquery(); /*中间的这个位置用于我们测试代码*/ /*关闭数据库连接 与 释放类*/ db_close(); $empire=null; ?>
The first test object: query
- query() executes mysql_query()
- The return value also follows the explanation of mysql_query() in the PHP manual, but if the execution fails, it is different from mysq_query
- The test code is as follows (removing the lengthy comments):
<?php include("../../class/connect.php"); include("../../class/db_sql.php"); $link=db_connect(); $empire=new mysqlquery(); function hr(){ echo ' <hr /-->'; } $sql=$empire->query("select id,title from {$dbtbpre}ecms_news"); var_dump($sql); hr(); //如语句执行成功则返回true $sql=$empire->query("UPDATE {$dbtbpre}ecms_news set title='标题' where id=1"); var_dump($sql); hr(); //如语句执行失败则终止执行并返回错误语句 下面的语句用了不存在的字段 $sql=$empire->query("UPDATE {$dbtbpre}ecms_news set titlesss='标题' where id=1"); var_dump($sql); hr(); db_close(); $empire=null; ?>
The source text about the query object is as follows: In the ninth line of e/class/db_sql.php; the PHP manual for die() explains that "the die() function outputs a message and exits the current script"; so the third var_dump() and hr() under the test statement exited without executing;
function query($query) { $this->sql=mysql_query($query) or die(mysql_error().''.str_replace($GLOBALS['dbtbpre'],'***_',$query)); return $this->sql; }
The second test object: query1
The object query1 is the same as mysql_query(), and the longer Chinese characters have been deleted to save space.
<?php include("../../class/connect.php"); include("../../class/db_sql.php"); $link=db_connect(); $empire=new mysqlquery(); function hr(){ echo ' <hr /-->'; } $sql=$empire->query1("select id,title from {$dbtbpre}ecms_news"); var_dump($sql); hr(); //如语句执行成功true $sql=$empire->query1("UPDATE {$dbtbpre}ecms_news set title='测试更新标题' where id=1"); var_dump($sql); hr(); //如语句执行失败则返回FLASE $sql=$empire->query1("UPDATE {$dbtbpre}ecms_news set titlesss='测试更新标题' where id=1"); var_dump($sql); hr(); db_close(); $empire=null; ?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The mobile settings of Empire CMS are located in the "Mobile Template" of the "Template Management" module. The specific steps include: enabling the template, selecting the application channel, editing the template content, and saving the settings.

The Empire CMS sitemap can be found by accessing the config.inc.php file and checking the dositemap settings. If set to "on", sitemap is enabled. The sitemap path is located in the sitemapurl setting and can be accessed via a browser or downloaded via FTP.

The ideal location for the Empire CMS template file is /e/template/default/skin/default/. Secondly, it can also be placed in /e/data/skins/ and /e/skin/. You need to pay attention to maintaining the folder structure and setting file permissions. and regular backups.

The Imperial CMS database configuration file is located in the website root directory e/config/db.inc.php. It contains the following configuration information: $dbhost: database server address $dbuser: database user name $dbpass: database password $dbname: database name $dbport :Database port $dbcharset: Database character set

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

Empire CMS template download location: Official template download: https://www.phome.net/template/ Third-party template website: https://www.dedecms.com/diy/https://www.0978.com.cn /https://www.jiaocheng.com/Installation method: Download template Unzip template Upload template Select template

The imperial cms Baidu active push plug-in is located in the root directory /e/api/baidu/push.php. The specific configuration steps are as follows: 1. Upload the plug-in file to the specified path. 2. Configure the "Baidu Active Push" option in the Imperial CMS background, including push address, API Key and push interval. 3. Get Baidu push information: Push address: https://data.zz.baidu.com/urls?site=YOUR_SITE&token=YOUR_API_KEY, API Key: log in to Baidu search resource platform to obtain. 4. Update the API Key regularly and set a reasonable push interval.

The automatic publishing interface of Empire CMS is located at /e/api/web/postinfo.php. The usage steps are as follows: visit /e/api/web/postinfo.php address and use HTTP POST to submit the article title, column ID, category ID, author and article The content and other data interfaces will return a response in JSON format, which contains the publishing results and article ID.
