我正在使用PHP PDO类,您可以看到here并遇到一些问题。如果我将使用简单的select where,这就是代码:
$id = 54;
$bind = array(
":aid" => $id,
":aid" => $id2,
);
$results = $db->select("accounts", "AccountID = :aid", $bind);
这是来自claass的select函数:
public function select($table, $where="", $bind="", $fields="*") {
$sql = "SELECT " . $fields . " FROM " . $table;
if(!empty($where))
$sql .= " WHERE " . $where;
$sql .= ";";
return $this->run($sql, $bind);
}
我的问题是我想在那里执行OR。我怎么能这样做?
答案 0 :(得分:2)
从选择功能中,您只需使用
即可$id = 54;
$something=123;
$bind = array(
":aid" => $id,
":something" => $something
);
$results = $db->select("accounts", "AccountID = :aid OR AccountID=:something ", $bind);