I' am using MySQLI Wrapper as stated in the docs about running rawQuery. Since it doesn't have any function to search database I had write my own. Below is the code that am using.
$songs = $db->ObjectBuilder()->rawQuery('SELECT * FROM songs WHERE song_name LIKE ?', array('%test%'));
The query returns empty results, yes there are data in the database which should match the search keyword. Any idea what am I doing wrong in the Query?
I don't know the structure and content of songs
but your code seems to be correct. You can try if problem persists when array('%test%')
is inserted into query by inserting this manually. Try to execute this:
$db->ObjectBuilder()->rawQuery("SELECT * FROM songs WHERE song_name LIKE '%test%'");
If this query returns empty results then I would suspect that something wrong is either in your query or in the database. Otherwise, there is something wrong with rewriting parameters by rawQuery
function.