Mysqli fetch_assoc vs fetch_array

前端 未结 4 1930
心在旅途
心在旅途 2020-12-03 05:33

When I\'m returning one row from a table, to gather the results I usually use e.g.:

$info = $result->fetch_assoc(); 

What is the differ

4条回答
  •  眼角桃花
    2020-12-03 05:54

    (PHP 5) From: http://php.net/manual/en/mysqli-result.fetch-array.php

    mysqli_result::fetch_array -- mysqli_fetch_array — Fetch a result row as an associative, a numeric array, or both

    So effectively, fetch_array() and fetch_assoc() can be essentially equivalent calls. As for performance, I recommend using whichever call that results in more readable code and only be concerned about the performance after you've clearly identified the call as a performance issue. It's more likely that you've got more serious performance issues where you least expect them to be.

提交回复
热议问题