当前位置: 帮助文档 > > 正文

php编写数据库操作:修改一条数据


$db->update 操作方法

1.首先加载对应的数据库类
$db = load_class('db');
2.然后调用update方法
$update = $db->update($table, $data, $where = ''); //$table 表名 $data 要更新的数据内容,参数可以为数组也可以为字符串,建议数组 $where更新数据的条件,可以是数组或者字符串


  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | wuzhicms [ 五指互联网站内容管理系统 ]
  4. // | Copyright (c) 2014-2015 http://www.wuzhicms.com All rights reserved.
  5. / | Licensed ( http://www.wuzhicms.com/licenses/ )
  6. // | Author: wangcanjia <phpip@qq.com>
  7. // +----------------------------------------------------------------------
  8. defined('IN_WZ') or exit('No direct script access allowed');
  9. load_class('admin');
  10. class index extends WUZHI_admin {
  11. private $db;
  12. function __construct() {
  13. $this->db = load_class('db');
  14. }
  15. function edit() {
  16. $update = $this->db->$db->update($table, $data, $where = '');//更新之后返回是以boolean类型返回
  17. }
  18. }