Originally think of the array $customerid split out, to determine the length of different variables, the number of variables to be judged, and then write the bottom of the MySQL query, some trouble, ask there is no good way, thanks!
---------------------------------------------
$customerid:
Array (size=2)
0 = String ' 5 ' (length=1)
1 = String ' + ' (length=2)
----------------------------------------------
$customer->where ("id in". $customerid)->count (); That's the point, of course, it's not right to put the array directly here.
Reply to discussion (solution)
Because you want to count the MySQL statement below, it's best to have one. It is also not good to loop a query in one line.
foreach ($customerid as & $value) {
$count = $customer->where ("id in".) ($value) ")->count ();
$arrcount [] = $count;
}
$count = 0;
foreach ($arrcount as & $value) {
$count = $count + $value;
}
It's settled, and the new problem is coming.
How to control, different conditions, (show Top 10 records)
For example
WHERE ("ID in". (3)) there are 2
WHERE ("ID in". (2)) there are 1
Actually, what products are collected by each user. One user may have more than one collection.
I want to show them the top 10 summary, with a joint query, do not know how many times, and then cycle count, good trouble.
Is the best way to change the table structure?
In the Product table, add a userid? A user can collect different products? It seems that the design can
The first question, if it is to check the single ID, the direct id = XX can be, no need to use in
If you want to check multiple IDs, combine the array with the IMPLODE function into the ID in (1, 2, 3) string of this format
The last question, if your requirement is to output a list of users, and output each of the top 10 favorites, you should consider caching
Every cool