Jump to content

Replicate MySQL UNION with selectors


adrian
 Share

Recommended Posts

Is this possible?

I am trying to combine results of more than one $pages->find. I know I could append the results of one to the pagearray of the other, but I want to be able to apply a limit to the combined results of both, sorted by modified, before returning the results.

Thanks 

Link to comment
Share on other sites

Thanks - I guess it's not a big deal to do it that way. I think I am just so used to using SQL to do most of the work first that the idea of returning so many results  just to later throw them out seems weird :)

Link to comment
Share on other sites

$select1 = 'template=bluskchug, ...whtevr u want'; 
$select2 = 'template=chishpahjung, ...whaevr u.like';
$select3 = 'sort=...you say, limit=10'; 
$select3 .= ", id="; // leav.thi s
$findre = new PageFinder();
$res1 = $findre->find(new Selectors($select1));
$res2 = $findre->find(new Selectors($select2)); 
foreach(array_merge($res1, $res2) as $hi) $select3 .= "$hi[id]|"
$res3 = $findre->find(new Selectors(rtrim($select3, '|'));  
$ids = array();
foreach($res3 as $hi) $ids[] = $hi['id'];
$yopages = $pages->getById($ids);  

or.u jus.use sql.queery

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...