+ 1

Php question

this is the code <?php $result=$conn->query("select * from tablename where ID='$ID' "); $row=mysqli_fetch_object($result); ?> my question is, do "mysqli_fetch_object" make the $row an object ? if yes, why do we have to make it an object ? why do we have to store the $result in the $row and not use the $result directly instead ,to extract the information ? help ... php newbie here

25th Mar 2018, 5:37 PM
Naruto Shippuden
Naruto Shippuden - avatar
2 Réponses
0
You are using the Object-oriented method. you can store it traditionally.
25th Mar 2018, 6:35 PM
Jean-louis du Plessis
Jean-louis du Plessis - avatar
0
I would use $row = $result->fetch_assoc() and get the associative array already returned in the result. Unless there is something requirement to convert to an object don't. Result contains more than just the data. For example, it also contains a count of returned results: $result->num_rows
25th Mar 2018, 6:43 PM
Adam
Adam - avatar