Retrieving multiple values associated with a single record. MySQL PHP Codeigniter -


I need help with a query on the following tables.

  table user (user_id char 5), user name four (12), column x four (10)); * Telephone (user_id char (5), phone number number (10), primary (Y, n) four (1)); *  

Both tables are linked to user_id, each user can have multiple phone numbers here.

I have to take out a group of users and their phone numbers. I am trying to do the following

In the model

  $ This- & gt; Db- & gt; Where ('column', 'some'); $ Query = $ this- & gt; Db- & gt; Receive ('user'); Foreign currency ($ query-> result () as $ line) {$ this- & gt; Db- & gt; Select ('phone_number'); $ This- & gt; Db- & gt; Where ('user_id', $ line-> user_id); $ This- & gt; Db- & gt; Where ('primary', 'y'); $ Q = $ this- & gt; Db- & gt; Get ('phone'); }  

How do I return to the model and display multiple phone numbers for each user, when my first $ query returns many users ??

Thanks in advance, Prime

Try joining:

  $ query = $ this-> more; - (gt; b ',' a.user_id = a.user_id ') - & gt; Where (array (- (* * as 'user') - & gt; 'A.columnx' = & gt; 'some')); - & gt; Find (); Var_dump ($ query- & gt; result ());  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -