


How to use fetch() and fetch1() in the secondary development of Empire CMS?
fetch() and fetch1() is a function commonly used in the secondary development of Imperial CMS. The correct writing method and some uses of fetch() and fetch1() are introduced below:
(Note: The fetch() and fetch1() functions are located in e/ class/db_sql.php file)
1.fetch()
Generally we use it to loop out the list or list multiple pieces of information; for example, the following example obtains the member group ID All member IDs and user names that are 1; the parameters of fetch() are the results of SQL statement execution, that is, query() is executed first; and then the execution results of query() are used as parameters for fetch();
The code is as follows:
query( "select userid,username from {$dbtbpre}enewsmember where groupid=1" ); while ( $r = $empire ->fetch( $sql )){ echo $r [userid]. '---' . $r [username].' '; } db_close(); $empire =null;
2.fetch1()
Simply put, we only use it when querying a piece of information, such as getting the member information with USERID 1; The difference from fetch() is that the parameters of fetch1() are SQL statements rather than execution results, so just go in directly without using the SQL statement for the second time; fetch1() only takes one piece of data;
The code is as follows
fetch1("select userid,username from {$dbtbpre}enewsmember where userid=1 limit 1"); echo $r[userid].' '; echo $r[username].' '; db_close(); $empire=null;
Let’s discuss further:
1. When fetching a piece of information, both fetch() and fetch1() are Yes, the code is as follows:
The code is as follows:
fetch1("select id,title from {$dbtbpre}ecms_news where classid=34"); print_r($r1); echo '<hr>'; $sql=$empire->query("select id,title from {$dbtbpre}ecms_news where classid=34"); $r=$empire->fetch($sql); print_r($r); echo '<hr>'; db_close(); $empire=null;
2. If you want to use fech1() to loop data, you can test the following code, you will I found that the result was tragic, an infinite loop, so I quickly closed the browser;
The code is as follows:
fetch1("select id,title from {$dbtbpre}ecms_news where classid=34")){ echo $r1[title]; } db_close(); $empire=null;
3.fetch() is the same dead-end loop writing method;
The code is as follows: :
query("select id,title from {$dbtbpre}ecms_news where classid=341"); $r=$empire->fetch($sql); while($r)){ echo $r[title].' '; } db_close(); $empire=null;
4.Why. . . ;trylife once said that there is no truth without code, so let’s take a look at the content in the source file: Location: e/class/db_sql.php
The code is as follows:
//执行mysql_fetch_array() function fetch($sql)//此方法的参数是$sql就是sql语句执行结果 { $this->r=mysql_fetch_array($sql); return $this->r; } //执行fetch1(mysql_fetch_array()) //此方法与fetch()的区别是:1、此方法的参数是$query就是sql语句 //2、此方法用于while(),for()数据库指针不会自动下移,而fetch()可以自动下移。 function fetch1($query) { $this->sql=$this->query($query); $this->r=mysql_fetch_array($this->sql); return $this->r; }
①.See fetch1() There are more lines in the function body than fetch(), "$this->sql=$this->query($query);"; fetch1() executes query() first; so when getting a line of information, just fetch1 directly (), type less code;
②. The infinite loops in 3 and 4 above are PHP writing problems. The while($r=$empire->fetch($query)) function first fetches the query results The first line of content, after which the record pointer automatically moves to the next line; Note: mysql_fetch_array only obtains the first line of data in the query result; mysql_fetch_array() that is not written in the while() brackets can only read the first line of data. , so there is an endless loop of birds!
The above is the detailed content of How to use fetch() and fetch1() in the secondary development of Imperial CMS. For more information, please follow other related articles on the PHP Chinese website!

管理员表有:1、phome_enewsuser,是管理员记录表;2、phome_enewsdolog,是管理员操作记录表;3、phome_enewsgroup,是管理员用户组数据记录表;4、phome_enewslog,是管理员登陆日志;5、phome_enewsloginfail,是管理员登陆失败记录表;6、phome_enewserrorclass,是管理员错误报告记录表。

帝国cms把静态改成伪静态的方法:1、创建.htaccess文件;2、修改网站配置文件;3、重新生成所有页面;4、配置伪静态规则;5、保存并关闭文件即可。

帝国cms404页面的设置步骤为:1、登录到帝国CMS的后台管理界面;2、导航到"内容"或"站点管理"等相关菜单选项;3、找到和选择"404页面"或"错误页面"选项;4、选择使用已有页面或者创建一个新页面作为404页面;5、在新页面编辑器中,编写404页面的内容;6、保存页面并将其设置为404页面;7、更新网站设置;8、保存设置并测试404页面即可。

帝国cms可以删除模块。删除模块的方法:1、登录帝国CMS后台,依次点击“系统”-“系统设置”-“系统参数设置”-“关闭相关功能”,根据自己网站的需求,自行勾选设置来关闭对应的模块功能;2、关闭功能后,删除对应模块的在e目录下的子目录;3、修改e目录下的php文件,在文件第二行加上代码“exit();<?php exit()”,并保存修改即可。

帝国cms留言板是“phome_enewsgbook”表;帝国cms留言分类表是“phome_enewsgbookclass”;帝国cms会员空间留言表是“phome_enewsmembergbook”。

帝国cms连接不上数据库的解决办法:1、打开帝国CMS数据文件的根目录;2、找到并打开“/e/config/config.php”文件;3、将数据库名称以及数据库用户名即数据库密码修改保存后替换空间文件即可。

在帝国cms中,封面模板是指网站频道页面使用的模板,可以制作跟首页一模一样的封面页面;封面模板共使用在两个地方:非终极栏目和专题。封面模板的使用,一般是该栏目为父级栏目(非终级栏目),封面模板的目的就是调用各个子栏目(终级栏目)文章。

帝国cms修改数据库文件的方法:1、打开控制面板,找到phpMyAdmin或类似的数据库管理工具;2、选择您要修改的数据库;3、点击您要修改的表格;4、点击您要修改的字段;5、根据需求,修改相应的属性和值;6、保存您所做的修改;7、重复步骤三至六,对其他字段进行相应的修改即可。


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

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
