valan Posted March 11, 2016 Share Posted March 11, 2016 It should return array [user_id => [order_id1, order_id2, ...], ...] where both users and order pages should be initially (but in the same query) filtered based on some PW $users_selector and $orders_selector. Each order page has field $order_user (e.g. it links order and user). How SQL query should look like? After few hours of own experiments I probably need help to combine SQL and PW selectors. Thanks! Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 11, 2016 Share Posted March 11, 2016 I'm not sure why you'd need sql for that. Sql queries cannot supply you with a datastructure like you suggested it, it can only return data in a tabular structure, so you need to build up the array no matter how you tackle the problem. $usersWithOrders = $users->find("orders.count>0"); $orders = $pages->find("template=order"); $byUser = array(); foreach($usersWithOrders as $u){ $byUser[$u->id] = $orders->find("id=$u->orders"); } 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now