0

I have an SQL query which I'm adding to a small search plugin, however when I run the SQL in MySQL it works and results are found, however no rows are being returned when running the code in the plugin. Any ideas?

$query = ee()->db->query('
    SELECT c.cat_url_title, c.cat_name, ch.channel_name FROM exp_categories c
    LEFT JOIN exp_channels ch ON ch.cat_group = c.group_id
    WHERE c.cat_name LIKE "%' . ee()->db->escape_str($keywords) . '%"
');

UPDATE (moved from further answer) Thanks. I was being thick! the query was working correctly. I was sending it the wrong parameter

2 Answers 2

3

I ran it and I'm getting results just fine.

Are you outputting the results correctly?

$query = ee()->db->query('SELECT cat_url_title, cat_name, ch.channel_name  FROM exp_categories c
        LEFT JOIN exp_channels ch ON ch.cat_group = c.group_id
        WHERE c.cat_name LIKE "%'.ee()->db->escape_str($keywords).'%"');
foreach($query->result_array() as $row)
{
    echo $row['cat_name']."<br>";
}
0

Thanks. I was being thick! the query was working correctly. I was sending it the wrong parameter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.