Battlezz Posted October 23, 2021 Share Posted October 23, 2021 hello, i am currently trying to get the data back from sql / database aka invoice data. the method im currently using is $user_in = (\IPS\Db::i()->select('*', 'nexus_invoices', 'i_member',$member_id ))->first(); but the problem is the ->first(); is its only responding the first invoice, if there is 2 wondering if their is any other way to get all data with the correct member id Link to comment Share on other sites More sharing options...
0 SamCheets Posted October 26, 2021 Share Posted October 26, 2021 (edited) $users_in = (\IPS\Db::i()->select('*', 'nexus_invoices', 'i_member',$member_id )); foreach ($users_in as $user_in) { //example usage of it //echo $user_in['ps_id'] } also, using first-> without checking it will give internal server error. If you only want to get first query the way you should use is: $user_in = (\IPS\Db::i()->select('*', 'nexus_invoices', 'i_member',$member_id )); if (count($user_in) > 0) { $user_in = $user_in->first(); } Also, forgot to mention, you should put your where statement in array. array('i_member=?', $member_id') Edited October 26, 2021 by SamCheets Link to comment Share on other sites More sharing options...
0 Stevew Posted October 23, 2021 Share Posted October 23, 2021 Well, `->first()` is named for what it's used for. Getting the first results from the query. If you have multiple records you want to use, then remove the `->first()` and treat the variable `$user_in` as a collection. That means you either need to iterate on the result and do something or use it as a whole. With the correct member id is where you set the `where` clause for your query. If something is unclear, please refer to the developer documentation: https://invisioncommunity.com/developers/docs/general/ Link to comment Share on other sites More sharing options...
0 Battlezz Posted October 23, 2021 Author Share Posted October 23, 2021 1 hour ago, Stevew said: Well, `->first()` is named for what it's used for. Getting the first results from the query. If you have multiple records you want to use, then remove the `->first()` and treat the variable `$user_in` as a collection. That means you either need to iterate on the result and do something or use it as a whole. With the correct member id is where you set the `where` clause for your query. If something is unclear, please refer to the developer documentation: https://invisioncommunity.com/developers/docs/general/ do you have any sort of example, i cannot find anything on the documentation about this. Link to comment Share on other sites More sharing options...
0 Battlezz Posted October 23, 2021 Author Share Posted October 23, 2021 edit : nvm found the fix Link to comment Share on other sites More sharing options...
0 Administrator Logan_Rocks Posted November 1, 2021 Administrator Share Posted November 1, 2021 The question(s) in this support topic have been answered and the topic author has resolved their issue. This topic is now closed. If you have other questions, please open a new topic. Link to comment Share on other sites More sharing options...
Question
Battlezz
hello, i am currently trying to get the data back from sql / database aka invoice data.
the method im currently using is
$user_in = (\IPS\Db::i()->select('*', 'nexus_invoices', 'i_member',$member_id ))->first();
but the problem is the ->first(); is its only responding the first invoice, if there is 2
wondering if their is any other way to get all data with the correct member id
Link to comment
Share on other sites
5 answers to this question
Recommended Posts