phpmysqlprepared-statement

How to bind multiple arguments to a PHP prepared statement?


"SELECT id as Id from dbTable WHERE code = ? AND CURDATE() BETWEEN 
start_date AND end_date AND offerId IN ('12321', '12124')";
//Passing arguments for the query
$args = array_merge(array(51342),$offerid);

//Execute the prepared query
$statement->execute($args);

Now array(51342) represents combination of code+value, aside my database has value, code columns and so I want a query which would look logically like:

"SELECT id as Id from dbTable WHERE code and value 
//(Note here I do not know the syntax, 
//what am looking at is (code+value = ?), please advise on query) = ? 
AND CURDATE() BETWEEN start_date AND end_date AND offerId IN ('12321', '12124')";

Solution

  • Just got one in the search:

    "SELECT id as Id from dbTable WHERE concat(code, value) = ? 
    AND CURDATE() BETWEEN start_date AND end_date AND offerId IN ('12321', '12124')"
    

    Not sure though this would work perfectly fine !!!

    Thanks !!!