phpmysqlcodeigniterwhere-clauselogical-grouping

How to write a CodeIgniter query with OR LIKE and not equals expressions


I have a search box for each status of an item!

When I search, is this the right way to do it?

SELECT *
FROM (`site_pages`)
WHERE  `title`  LIKE '%php%'
   OR  `content`  LIKE '%php%'
HAVING `status` != 'deleted'
   AND `status` != 'concept'

When no search is committed I just use

... WHERE'status' != 'deleted' AND 'status' != 'concept'

Solution

  • A few possibilities for improvement:

    Otherwise it looks like pretty standard SQL.