Manixat Posted March 2, 2013 Share Posted March 2, 2013 (edited) 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 ? Edited March 2, 2013 by Manixat Quote Link to comment https://forums.phpfreaks.com/topic/275119-mysqli-and-arrays/ Share on other sites More sharing options...
Solution Barand Posted March 2, 2013 Solution Share Posted March 2, 2013 mysqli_result::fetch_all Quote 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! Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/275119-mysqli-and-arrays/#findComment-1416209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.