Saturday 15 March 2014

php - Adding an array to a MySQL column in SELECT -


I have an array with a set of users and their related actions:

  $ Some_array = array ([user_id] => array ([0] = & gt; 4 [1] => 3 [2] => 5 [3] => 1] [karma] = > Array ([0] = & gt; 12 9 [1] => 87 [2] => 13 [3] = & gt; 20))  

I was thinking that when you are retrieving the user data from a MySQL table, you can add an additional column with the Karma array and sequence by that extra column:

  $ Query = 'select user*, Extra_column as {{$ Some_array ['karma']}} WHERE user.id IN '. (Implode (',', $ some_array ['user_id']). 'Order by extra ID';  

Any ideas? Is this possible?

  SELECT id, ELT (field (id, 4, 3, 5, 1), 129, 87, 13, 20) Choose Karma (Select 4As Union Union All Select All as Union All 5 Union Select All 1 AS ID) Q Where ID (4, 3, 5, 1) Order By  

No comments:

Post a Comment