I just wanted a little bit of information on MYSQLI_NUM. And is it part of PHP or MySQL.
The fetch_array() / mysqli_fetch_array() function fetches a result row as an associative array, a numeric array, or both. Note: Fieldnames returned from this function are case-sensitive.
fetch_array returns value with indexing. But Fetch_assoc just returns the the value. here array location 0 contains 11 also this location name is 'id'. means just returns the value.
MYSQLI_BOTH will create a single array with the attributes of MYSQLI_NUM and MYSQLI_ASSOC. From the documentation: By using the MYSQLI_ASSOC constant this function will behave identically to the mysqli_fetch_assoc(), while MYSQLI_NUM will behave identically to the mysqli_fetch_row() function.
The mysqli_result class ¶Represents the result set obtained from a query against the database.
MYSQLI_NUM is a constant in PHP associated with a mysqli_result. If you're using mysqli to retrieve information from the database, MYSQLI_NUM can be used to specify the return format of the data. Specifically, when using the fetch_array function, MYSQLI_NUM specifies that the return array should use numeric keys for the array, instead of creating an associative array. Assuming you have two fields in your database table, "first_field_name" and "second_field_name", with the content "first_field_content" and "second_field_content"...
$result->fetch_array(MYSQLI_NUM);
fetches each row of the result like this:
array(
0 => "first_field_content",
1 => "second_field_content"
);
Alternatively...
$result->fetch_array(MYSQLI_ASSOC);
fetches an array like this:
array(
"first_field_name" => "first_field_content",
"second_field_name" => "second_field_content"
);
Using the constant MYSQLI_BOTH will fetch both.
It is a PHP constant used in mysqli_fetch_array()
This tells the function that you want it to return a record from your results as a numerically indexed array instead of an associative one (MYSQLI_ASSOC) or both (MYSQLI_BOTH).
Alternatively, you can just use mysqli_fetch_row() to do the same thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With