Medoo - 更新表格行匹配字段

时间:2013-07-18 22:12:34

标签: php

我正在使用Medoo但知道很少的php,下面的更新工作正常,但我只希望它在clientId匹配发布时更新:

$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']
));

//$_POST["clientId"];

我使用的是较新版本的PHP,对语法有点困惑,以下是旧版PHP的用法

http://medoo.in/api/update

1 个答案:

答案 0 :(得分:2)

我假设您在该表中有clientId字段,您可以尝试:

$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']
));

希望它有所帮助。