mysqli_query - return values

后端 未结 3 460
南旧
南旧 2021-02-10 03:22

I am using the PHP function mysqli_query to run a SELECT query.

What does mysqli_query return if the query runs successfully, but

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-10 03:57

    if ($result = $mysqli->query("SELECT * FROM data"))
    {
        $count = $result->num_rows; 
        printf("Result set has %d rows.\n", $count);
        $result->close();
    }
    

    From reference:

    Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.

提交回复
热议问题