Mysqli_stmt how to dynamically bind parameter values?

Source: Internet
Author: User
Mysqli_stmt how to dynamically bind parameter values????
Mysqli_stmt method Bind_param, requires a one-time parameter all passed in, equivalent to the number of parameters and order must be hard-coded, but in practice may not be able to get
For example, when you do a query, the query statement will be written like this
$sql = "SELECT * from MyTable where price > 100";
if (...)
$sql. = "and Price <?";
if (...)
$sql. = "and CreatedDate <?";
if (...)
$sql. = "and EmployeeID =?";
......

How should I pass in the parameters?
You don't have to suggest how I can improve the way SQL is written, and there will be other similar SQL, and I'm just going to give you an example of how to set parameters dynamically.

Thank you!

Share to:


------Solution--------------------
Call_user_func_array

  • 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.