无法解决此bindParam问题

时间:2019-03-28 10:43:47

标签: php pdo

我正在尝试使用PDO从MySql数据库中获取一些数据,但是无论我做什么,使用准备好的语句时我什么也无法得到……请告诉我我做错了。

以下代码运行,但不返回任何内容。

try {
    $dbh = new PDO('mysql:host=localhost;dbname=banim', 'root', '');
    $uName = "banim";       //$_POST['uName'];
    $email = "Rabak@gmail.com";            //$_POST['email'];
    $query = $dbh->prepare("SELECT * from users WHERE email = :email OR WHERE uName = :name");
    $query->setFetchMode(PDO::FETCH_ASSOC);
    $query->bindParam(":name", $uName);
    $query->bindParam(":email", $email);
    $query->execute();
    foreach ($query as $row) {
        print_r($query);
    }
} catch (PDOException $e) {
    echo "PDOException: " . $e->getMssage() . PHP_EOL;
}

1 个答案:

答案 0 :(得分:0)

Alive To Die写的是正确的,并且SQL字符串中还有一个额外的WHERE,这也弄乱了答案,这是最终代码:

const values = {
  ...
  b: { type: "FETCH_DONE", payload: expected },
  c: NEEDS TO BE ANONYMOUS
};

...
const output$ = fetchApi(action$, state$);

// This fails due to the anonymous function
expectObservable(output$).toBe('---(bc)--', values);