Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findWhere after Criteria #67

Open
carlituxman opened this issue Dec 26, 2015 · 3 comments
Open

findWhere after Criteria #67

carlituxman opened this issue Dec 26, 2015 · 3 comments

Comments

@carlituxman
Copy link

I'm doing a criteria before a query like:

$all = $this->repo->findWhere(['status_id'=> $status->id, 'user_id'=> 1])->count();

my criteria is like this:

public function apply($model, Repository $repository)
{
$users = User::filtered()->lists('id')->toArray();
$model = $model->where('user_id', $users);
return $model;
}

the result of criteria is correct, but when I do the findWhere after it returns 0 (and should be return more)

@carlituxman
Copy link
Author

the problem is because I have a loop after the criteria, only do it well in the first iteration

I'm researching what's happen...

the problem is because (I think) the criteria apply in every loop again

@carlituxman
Copy link
Author

The problem is because in every iteration the query is stacked
I solve using:
$this->repo->skipCriteria();
$this->repo->pushCriteria(new myCriteria());

in every iteration

@carlituxman
Copy link
Author

this should be cleared in every find, findWhere, ... ??

@carlituxman carlituxman reopened this Dec 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant