上一篇《删除方法:Delete API-Medoo使用指南》中介绍了如何使用Medoo的Delete方法来删除数据,本篇将教你使用Replace方法来替换数据库中的数据。php
替换方法:Replacehtml
把数据库中的旧数据替换成新的。数据库
//方式1 replace($table, $column, $search, $replace, $where) //table [string]: 表名 //columns [string/array]: 将要进行替换数据的目标字段 //search [string]: 搜索值 //replace [string]: 替换值,替换找到的[搜索值] //where (可选) [array]:WHERE子句筛选记录 //方式2 replace($table, $column, $replacement, $where) //table [string]: 表名 //columns [string/array]: 将要进行替换数据的目标字段 //replacement [array]: 替换值数组,以[搜索值]做为key,以[替换值]做为value。 //where (可选) [array]:WHERE子句筛选记录 //方式3 replace($table, $columns, $where) //table [string]: 表名 //columns [string/array]: 将要进行替换数据的目标字段 //where (可选) [array]:WHERE子句筛选记录
返回值: [number] 受到影响的行数数组
提示:这个函数有不少用法。
函数
$database = new medoo("my_database"); $database->replace("account", "type", "user", "new_user", [ "user_id[>]" => 1000 ]); $database->replace("account", "type", [ "user" => "new_user", "business" => "new_business" ], [ "user_id[>]" => 1000 ]); $database->replace("account", [ "type" => [ "user" => "new_user", "business" => "new_business" ], "group" => [ "groupA" => "groupB" ] ], [ "user_id[>]" => 1000 ]);
Medoo版本: 0.9.1.1post
原文标题: 替换方法:Replace API-Medoo使用指南spa
原文连接: http://loiynet.dev.com/post/588.html.net