我正在使用Medoo。以下更新适用于单场匹配。如果与clientId和businessCity匹配,我想更新数据。
$database->update("clientInfo", array(
"businessName" => $_POST['businessName'],
"contactName" => $_POST['contactName'],
"businessEmail" => $_POST['businessEmail'],
"businessPhone" => $_POST['businessPhone'],
"businessWebsite" => $_POST['businessWebsite'],
"businessAddress" => $_POST['businessAddress'],
"businessAddress2" => $_POST['businessAddress2'],
"businessCity" => $_POST['businessCity'],
"businessState" => $_POST['businessState'],
"businessZip" => $_POST['businessZip']
), array(
"clientId" => $_POST['clientId'],
"businessCity" => $_POST['businessCity'],
));
我试过这样的。但不适合我。
答案 0 :(得分:1)
echo $database->last_query();
使用此函数检查为调试执行的SQL查询。
答案 1 :(得分:1)
从Medoo文档中了解相对论条件:http://medoo.in/api/where
只需为每个值添加AND
个连接器。
$database->update("clientInfo", array(
"businessName" => $_POST['businessName'],
"contactName" => $_POST['contactName'],
"businessEmail" => $_POST['businessEmail'],
"businessPhone" => $_POST['businessPhone'],
"businessWebsite" => $_POST['businessWebsite'],
"businessAddress" => $_POST['businessAddress'],
"businessAddress2" => $_POST['businessAddress2'],
"businessCity" => $_POST['businessCity'],
"businessState" => $_POST['businessState'],
"businessZip" => $_POST['businessZip']
), array(
'AND' => array(
"clientId" => $_POST['clientId'],
"businessCity" => $_POST['businessCity'],
)
));
答案 2 :(得分:0)
示例:
$datas = $db->update( "meta" , ["metalabel"=>$label[0][0]], ["AND"=>["metakey"=>"Collection", "metavalue"=>$_POST["metavalue"]] ] );
你必须使用逻辑运算符(AND或OR)设置一个数组,并且作为第一个值,你必须设置另一个数组...参见上面的例子