Manixat Posted March 2, 2013 Share Posted March 2, 2013 Hello freaks. Im new to OOP and I'm just starting to practice using this mysqli object. What I want to do is fetch a bunch of results and store them in an array and what I've done is this $result = $db->query("SELECT * FROM `stuff`"); while($row = $result->fetch_assoc()){ $stuff[] = $row; } and I can't help but wonder if there is a more efficient way of doing this, for example without looping ? Link to comment https://forums.phpfreaks.com/topic/275119-mysqli-and-arrays/ Share on other sites More sharing options...
Barand Posted March 2, 2013 Share Posted March 2, 2013 mysqli_result::fetch_all Link to comment https://forums.phpfreaks.com/topic/275119-mysqli-and-arrays/#findComment-1416004 Share on other sites More sharing options...
Manixat Posted March 2, 2013 Author Share Posted March 2, 2013 I went through that and couldn't figure out how it works, but now I can't figure out how could I not figure it out the first time. Thanks! Link to comment https://forums.phpfreaks.com/topic/275119-mysqli-and-arrays/#findComment-1416056 Share on other sites More sharing options...
AyKay47 Posted March 3, 2013 Share Posted March 3, 2013 Something important to note, only use fetch_all() in this particular case (e.g. when you only need to store the values into an array). In most other cases, fetch_all() is a complete waste of resources. Link to comment https://forums.phpfreaks.com/topic/275119-mysqli-and-arrays/#findComment-1416209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.