Hi everyone.
I wrote the following, which is a simple search, and which works.
[php]$searchTerm = ‘%’ . $searchTerm . ‘%’;
if ($stmt = $conn->prepare("
SELECT SQL_CALC_FOUND_ROWS id, title, description, keywords FROM images
WHERE title LIKE ?
OR description LIKE ?
OR keywords LIKE ?
ORDER BY createddate DESC
LIMIT “.$limit.” OFFSET “.$offset.”
")) {
$stmt->bind_param(“sss”,$searchTerm,$searchTerm,$searchTerm); // bind_param: i - integer, d - double, s - string, b - blob[/php]
The problem is that it searches by the full string only. I want to explode $searchTerm into separate words and bind them, so, no matter what the position or in what column the word is, as long as they all present somewhere.
I tried to bind the array I created from $searchTerm string with call_user_func_array, but I couldn’t make it work.