What do I do if the PHP array is the MySQL query condition where xx in array?

Source: Internet
Author: User
Tags mysql query
Ask the PHP array as the MySQL query condition where xx in array, how to handle
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.
------to solve the idea----------------------
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.