Welcome Guest, Not a member yet? Register   Sign In
Soft delete doesn't work with like?
#6

(11-02-2019, 06:40 AM)edica Wrote: Sorry if I'm wrong with something. : /


PHP Code:
$list = ['title' => $q'slug' => $q'body' => $q];
$model->orLike($list)->paginate(5


Using orLike() with paginate() generate the sql below:
But shows deleted.


Code:
SELECT COUNT(*) AS `numrows`
FROM `news`
WHERE `title` LIKE '%test%' ESCAPE '!'
OR  `slug` LIKE '%test%' ESCAPE '!'
OR  `body` LIKE '%test%' ESCAPE '!'
AND `news`.`deleted_at` IS NULL


In parentheses, it would work well.  Undecided

WHERE (`title` LIKE '%teste%' ESCAPE '!'
OR  `slug` LIKE '%teste%' ESCAPE '!'
OR  `body` LIKE '%teste%' ESCAPE '!')
AND (`news`.`deleted_at` IS NULL)

paginate() is another Model method. Internally it uses Model::findAll(), so it's not smart enough to put a parenthesis where it might be needed.

You can use groupStart() and groupEnd() to do that yourself in some circumstances. But I'm not sure it will work as desired when mixing Model ( find() ) and Builder ( orLike() )methods.
Reply


Messages In This Thread
Soft delete doesn't work with like? - by edica - 10-29-2019, 07:51 AM
RE: Soft delete doesn't work with like? - by dave friend - 11-02-2019, 08:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB