php oop statement->execute returns boolean

时间:2018-02-05 12:59:46

标签: php oop

so I have the following method:

public function checkLogin($username){
        $sql_login=$this->dbc->prepare("SELECT username FROM credentials WHERE username=?");
        $sql_login->bind_param("s", $username);
        $stmt=$sql_login->execute();
        $result = $stmt->get_result();
        return $result;

    }

By doing a var_dump (and removing $result = $stmt->get_result();) I can see that $stmt is passing a boolean.

I'm new to OOP in php. I'm thinking that get_result() function should get the result of the $stmt execution.

What am I doing wrong please ?

1 个答案:

答案 0 :(得分:4)

tranlistRealmDb对象转换为realm.executeTransactionAsync(new Realm.Transaction() { @Override public void execute(final Realm bgRealm) { tranlist.get(0).setExercise("New Exercise"); } }, new Realm.Transaction.OnSuccess() { @Override public void onSuccess() { // Transaction was a success. } }, new Realm.Transaction.OnError() { @Override public void onError(Throwable error) { // Transaction failed and was automatically cancelled. } }); 对象,它不返回结果集中的任何行

您还使用了来自$result = $stmt->get_result();的返回值,实际上它只是一个布尔值而不是您案例中名为mysqli::statement的语句对象,即mysqli::result

所以你需要添加一些内容来实际获取查询返回的行,例如$sql_login->execute();这样的

$sql_login