I was hoping for a solution which used IN without having to duplicate the AND statements.
Test Results
// Mittineague TEST START =======================
SELECT * FROM cities WHERE name LIKE %XXX%
OR (`cities`.`name` LIKE :variant_name_0
OR `cities`.`state_name` LIKE :variant_state_name_0)
OR (`cities`.`name` LIKE :variant_name_1
OR `cities`.`state_name` LIKE :variant_state_name_1)
OR (`cities`.`name` LIKE :variant_name_2
OR `cities`.`state_name` LIKE :variant_state_name_2)
OR (`cities`.`name` LIKE :variant_name_3
OR `cities`.`state_name` LIKE :variant_state_name_3)
// Mittineague TEST END =======================
// John_Betong:
$sql: SELECT *
FROM cities2
WHERE concat(name, " ", state_name) LIKE ?
AND concat(name, " ", state_name) LIKE ?
AND concat(name, " ", state_name) LIKE ?
AND concat(name, " ", state_name) LIKE ?
Params: array( %a%", "%b%", "%c%", "%d% )
I have tired to run the code within my script and am getting error…the first error occur when I add “string” to getParams( string $params=NULL) ( Catchable fatal error: Argument 1 passed to getParams() must be an instance of string, string given, called in C:**\index.php on line 64 and defined in C:*\index.php on line 25 )
without "string " getParams( $params=NULL)
Error!: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
please kindly help me correct the code…Thanks in advance for your time.
I try again with the code you post but getting this error…
Catchable fatal error: Argument 1 passed to getParams() must be
an instance of string, string given, called in
C:****index.php on line 67 and defined
in C:***t\index.php on line 25
Thanks so much for your time… the script is now working on my end…am so happy, you really safe my day…thanks once again.
Am thinking if I can improve the script to search for “car” if the user entered “cars” in the search box. From the online demo when I search for “berlin” it return result but when I search for “berlins” no result…