phpcms v9 数据库操作函数

时间:2023-03-09 16:55:46
phpcms v9 数据库操作函数

表明默认当前load_model('xxxx')模块所在表名xxxx

若要指定表名  则:操作在mysql.class.php中$this->db->select(...)

1、查询
  $this->select($where = '', $data = '*', $limit = '', $order = '', $group = '', $key='')   返回结果集数组
         条件 ,字段(id,name,email....),范围   排序方式,分组方式,按建名排序

phpcms v9 数据库操作函数
2、查询多条数据并分页

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

3、获取单条记录查询

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

4、直接执行sql查询

query($sql);

5、获取最后一次添加记录的主键号  insert_id()

6、执行更新记录操作   update($data, $where = '')  $data 建议为数组,$where 可为数组可为字符串

phpcms v9 数据库操作函数

7、执行删除记录操作   delete($where)

8、计算记录数         count($where = '')

9、获取最后数据库操作影响到的条数  affected_rows()

10、获取数据表主键     get_primary()

11、获取表字段     get_fields($table_name = '')

12、检查表是否存在   table_exists($table)

13、 检查字段是否存在  field_exists($field)