### update
**修改数据,该函数将根据参数中设置的条件而更新表中数据**
**参数**
conditions 数组形式,查找条件,此参数的格式用法与find/findAll的查找条件参数是相同的。
row 数组形式,修改的数据,
\* 此参数的格式用法与create的$row是相同的。在符合条件的记录中,将对$row设置的字段的数据进行修改。
~~~
public function update($conditions, $row) {
$where = "";
$row = $this->__prepera_format ( $row );
if (empty ( $row ))
return FALSE;
if (is_array ( $conditions )) {
$join = array ();
foreach ( $conditions as $key => $condition ) {
$condition = $this->__val_escape ( $condition );
$join [] = "{$key} = '{$condition}'";
}
$where = "WHERE " . join ( " AND ", $join );
} else {
if (null != $conditions)
$where = "WHERE " . $conditions;
}
foreach ( $row as $key => $value ) {
$value = $this->__val_escape ( $value );
//2011-01-04修改
//if ($value == 'NULL')
if ($value === 'NULL')
//2011-01-04修改
$vals [] = "{$key} = NULL";
else
$vals [] = "{$key} = '{$value}'";
}
$values = join ( ", ", $vals );
$sql = "UPDATE {$this->tbl_name} SET {$values} {$where}";
//echo $sql;
return $this->_db->query ( $sql );
}
~~~
- 架构
- 基础框架文档
- base/action(C层基类)
- protected 类定义
- __construct构造函数
- c_list
- c_index
- c_page
- c_pageJson
- c_listJson
- c_getByAjax
- c_getCountByName
- c_toAdd
- c_add
- c_init
- c_edit
- c_deletes
- c_ajaxdeletes
- c_saveBatch
- c_checkRepeat
- getDatadicts
- showDatadicts
- getDataNameByCode
- assign
- display
- view
- assignFunc
- model/base(M层基类)
- protected类定义(model)
- __construct
- find
- get_table_fields
- findAll
- findSql
- create
- delete
- findBy
- updateField
- query
- findCount
- update
- filterFunc
- filterField
- filterWithoutField
- filterCustom
- createBatch
- pageBySql
- listBySql
- pageBySqlId
- deletes
- 事务控制
- 获取对象数组
- addBatch_d
- add_d
- edit_d
- isRepeat
- 列表组件文档
- 基础表格
- 数据获取
- 表格数据显示
- 常用控制参数
- 表格右键扩展
- 表格扩展按钮
- 快速搜索
- 高级搜索(自定义视图)
- 表格注册事件
- 主从表格
- 可编辑表格
- 模块开发
- 开发案例
- 开发准则