简体   繁体   English

从数据库中选择任何项目都不返回1,为什么?

[英]Selecting no item from database returns 1, why?

Hello I have three small questions... I have this following query on mysql in my php... it delivers me the value 0 after selecting, even there is no bla = $bla - it should deliver me no value, why it deliveres me 0? 您好我有三个小问题...我在php中的mysql上有以下查询...选择后它为我提供了0值,即使没有bla = $ bla-它也不会给我带来任何价值,为什么会给我带来价值我0?

second question: the result is 1 - why does the selection succeed, even there is no bla = $bla? 第二个问题:结果是1-为什么选择成功,即使没有bla = $ bla?

third question: how can I know the selection wasn't succeded due to no item was selected because the WHERE condition did not succeeded. 第三个问题:由于WHERE条件未成功,我怎么知道由于未选择任何项而导致选择未成功。

$stmt= $this->conn->prepare("SELECT id FROM column WHERE bla = ?");
    $stmt-> bind_param("s", $bla);

        $result = $stmt->execute();
        $result = $stmt -> bind_result($id);

        echo $result;

In your code. 在您的代码中。 $result is the result of the query execution. $result是查询执行的结果。 It is not the data from the SQL statement. 它不是来自SQL语句的数据。

execute returns a boolean. execute返回一个布尔值。 See: http://php.net/manual/en/mysqli-stmt.execute.php 参见: http : //php.net/manual/en/mysqli-stmt.execute.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM