2

Mysqli prepared statements like the one below throw the following error when get_result() is called.

$stmt = $connection -> prepare("select column from table where id = ?");
$stmt -> bind_param("i", $id);
$id = 1;
$stmt -> execute() or trigger_error($stmt -> execute(), E_USER_ERROR);
$stmt_result = $stmt -> get_result();
$stmt_numrows = $stmt_result -> num_rows;
$stmt -> close();

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::get_result()

After reading the contribution section of the manual, it looks like it's a module issue. The doc here http://php.net/manual/en/mysqli-stmt.get-result.php states "Available only with mysqlnd", which is already enabled on the server.

enter image description here

It seems that everything works when I disable the mysqli extension and enable nd_mysqli instead (also recommended here: get_result() Doesn't Work even mysqlnd is enabled but with no further explanation).

I'd like to know what else I commit to by swapping these two extensions since they conflict with one another and can't be enabled together. Am I going to lose some features in the process? What's the difference between these two extensions exactly besides nd_mysqli including get_result()?

Will
  • 1,123
  • 1
  • 9
  • 22
  • 7
    This is a duplicate of the difference between pdo_mysql and nd_pdo_mysql? None of the answers mention nd_mysqli, so should one conclude by extrapolation? – Will Dec 20 '18 at 15:49
  • 3
    And none of them answer the question "what is the difference between them" – Eoin Nov 23 '20 at 22:54
  • You want to aslo load `nd_mysqli`; that's where it's at. unclick `mysqli` and do the `nd_` one – Martin May 06 '21 at 16:17
  • @Martin, Why??? Explain – Seth B May 12 '23 at 21:34
  • 1
    @SethB mysqli (with a backend to mysqlnd) is called `nd_mysqli` and is supplied by CloudLinux , while just mysqli (not `nd_mysqli`) links to the old libmysqlclient backend. The `nd_mysqli` PHP extension should be used in place of the mysqli PHP native extension. – Martin May 13 '23 at 20:04

0 Answers0