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
Activedataprovider set limit inside of query with union but should outside #65
Comments
It's a specific use case. // concept, did not test it
function wrapQuery(query)
{
$newQuery = new get_class($query);
$query->from(['originalQuery' => $query])
return $newQuery; // and then use this $newQuery for pagination
} I'm not sure whether we should add this complexity to ActiveDataProvider. |
Relates #7992 |
Not if you look at the topic @klimov-paul supplied. We should develop a solution that matches the expected result of the issue introduction. |
Would it make sense to:
That way create a more explicit and intuitive syntax. |
Yes. That's a good idea. |
agree, thats intuitive |
any progress on this? |
This issue is scheduled on future milestone. In you would like to help use with this issue - submit a pull request, we will highly appreciate it. |
SilverFire's solution work fine. protected function wrapQuery($query)
{
$newQuery = new ActiveQuery($query->modelClass);
$newQuery->from(['originalQuery' => $query]);
return $newQuery; // and then use this $newQuery for pagination
} |
I vote for fixes by SamMousa
$query->andFilterWhere(//... ); For now, my code look this for this case |
@githubjeka those issues sound like they are solvable.
To make sure a union query can still return
So suppose I have 2
The union query would do this:
Then after retrieving the results it would pass each row to Of course this approach could be simplified, in case both What we need to do is figure out some usages and expected results, for example:
Some of these uses, for example the last one, will be hard to properly implement in ALL cases; however this does not seem like a proper use to me that needs in depth support. |
@SamMousa
to `$union = $this->buildUnion($query->union, $params);
it works the union with sorting, limit, paging and it products a ActiveRecord and not array. now the result of this code |
@m2fik thanks, it helped me!!, my code became working. |
problev actualy!!! |
you can try this way, it's work for me.
|
What steps will reproduce the problem?
What is the expected result?
(SELECT * FROM
product
WHEREid
=1) UNION ( SELECT * FROMproduct
WHEREid
=2 ) LIMIT 12What do you get instead?
(SELECT * FROM
product
WHEREid
=1 LIMIT 12) UNION ( SELECT * FROMproduct
WHEREid
=2 )Additional info
The text was updated successfully, but these errors were encountered: