Home  >  Article  >  Backend Development  >  Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial

Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:34:141150browse

一、查

①select($where = '', $data = '*', $limit = '', $order = '', $group = '', $key='')

Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial
<span /*</span><span *
     * 执行sql查询
     * @param $where         查询条件[例`name`='$name']
     * @param $data         需要查询的字段值[例`name`,`gender`,`birthday`]
     * @param $limit         返回结果范围[例:10或10,10 默认为空]
     * @param $order         排序方式    [默认按数据库默认方式排序]
     * @param $group         分组方式    [默认为空]
     * @param $key          返回数组按键名排序
     * @return array        查询结果集数组
     </span><span */</span>
Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial

②listinfo($where = '', $order = '', $page = 1, $pagesize = 20, $key='', $setpages = 10,$urlrule = '',$array = array(), $data = '*')

Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial
<span /*</span><span *
     * 查询多条数据并分页
     * @param $where
     * @param $order
     * @param $page
     * @param $pagesize
     * @return unknown_type
     </span><span */</span>
Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial

③get_one($where = '', $data = '*', $order = '', $group = '')

Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial
<span /*</span><span *
     * 获取单条记录查询
     * @param $where         查询条件
     * @param $data         需要查询的字段值[例`name`,`gender`,`birthday`]
     * @param $order         排序方式    [默认按数据库默认方式排序]
     * @param $group         分组方式    [默认为空]
     * @return array/null    数据查询结果集,如果不存在,则返回空
     </span><span */</span>
Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial

④query($sql)

<span /*</span><span *
     * 直接执行sql查询
     * @param $sql                            查询sql语句
     * @return    boolean/query resource        如果为查询语句,返回资源句柄,否则返回true/false
     </span><span */</span>

二、增

①insert($data, $return_insert_id = false, $replace = false)

Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial
<span /*</span><span *
     * 执行添加记录操作
     * @param $data         要增加的数据,参数为数组。数组key为字段值,数组值为数据取值
     * @param $return_insert_id 是否返回新建ID号
     * @param $replace 是否采用 replace into的方式添加数据
     * @return boolean
     </span><span */</span>
Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial

②insert_id()

<span /*</span><span *
     * 获取最后一次添加记录的主键号
     * @return int 
     </span><span */</span>

三、改

①update($data, $where = '')

Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial
<span /*</span><span *
     * 执行更新记录操作
     * @param $data         要更新的数据内容,参数可以为数组也可以为字符串,建议数组。
     *              为数组时数组key为字段值,数组值为数据取值
     *                         为字符串时[例:`name`='phpcms',`hits`=`hits`+1]。
     *                        为数组时[例: array('name'=>'phpcms','password'=>'123456')]
     *                        数组的另一种使用array('name'=>'+=1', 'base'=>'-=1');程序会自动解析为`name` = `name` + 1, `base` = `base` - 1
     * @param $where         更新数据时的条件,可为数组或字符串
     * @return boolean
     </span><span */</span>
Sorting out the addition, deletion, modification and search operations of phpcms_PHP tutorial

四、删

① delete($where) 

<span /*</span><span *
     * 执行删除记录操作
     * @param $where         删除数据条件,不充许为空。
     * @return boolean
     </span><span */</span>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/752220.htmlTechArticle一、查 ①select($where = '', $data = '*', $limit = '', $order = '', $group = '', $key='') ②listinfo($where = '', $order = '', $page = 1, $pagesize = 20, $key='', $setpages =...
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