- Where Developers Learn, Share, & Build Careers


I also want to display their pictures in the user's search results. Not only avatar photo but also 3 photos photos are in extra table user_photos If I get a single line per user then the answer will be clear - internally but I will get multersonage for each user.

The first method I can use may include:

  Add user INNER from photos SELECT * photos.user_id = users.user_id  < / Pre> 

In this case I need some additional php code to merge results with the same user_id. Something like this:

  foreach ($ result as result of $) {if (isset ($ user [$ result ['user_id']] ['age'])) $ $ [$ Results ['user_id']] ['photo'] [] = $ result ['photo']; to continue; } $ User [$ result ['user_id']] ['age'] = $ result ['age']; $ User [$ result ['user_id']] ['photo'] [] = $ result ['photo']; I first need a first level loop for users to see and then $$$ [$ result [user_id ']] [' photo '] array for each user.  

Or I can use every result for the subquery, none of the options seems to be elegant, so I'm wondering if there is any other way. If not, there is probably a way to go to the first option, right?

You want to use, so that you will find something like this: the user is the form of photonmess from youtube In the User's User.User_ID group as being included in the photo:

  *, Group_concat (photos.name SEPARATOR '& amp;') .User ID;   

Then you can use the explosion () to open the array.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -