0

我正在使用 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'],
));

我试过这样。但不为我工作。

4

3 回答 3

1

echo $database->last_query();

使用此函数检查为调试而执行的 SQL 查询。

于 2014-11-17T17:39:32.880 回答
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'],
    )
));
于 2015-02-21T21:08:54.623 回答
0

例子:

$datas = $db->update( "meta" , ["metalabel"=>$label[0][0]], ["AND"=>["metakey"=>"Collection", "metavalue"=>$_POST["metavalue"]] ]  );

您必须使用逻辑运算符(AND 或 OR)设置一个数组,并且作为第一个值,您必须设置另一个数组...参见我上面的示例

于 2015-03-19T13:42:52.490 回答