Convert mysql subquery to join because phalcon php framework query builder does not support subquery -
i stacking write query couple of days, appreciate if can advice me. have written query using sub query limitation using phalcon php framework query builder not support sub query yet. need advice convert joins.
more details:
i need fetch posts in order latest entry in post_notification table. well, building application have rearrange posts list based on latest notification user received.
query written:
select p.* , ( select creation_date uo_notifications n n.post_id = p.id , n.user_id = ".$user_id ." order n.id desc limit 1 ) cdate uo_posts p p.user_id = ".$user_id." , p.group_id = ".$group_id." order cdate desc
posts table:
- id pk
- message
- group_id
- creation_date
post_notifications
- id pk
- user_id
- notify_msg
- post_id
- creation_date
thank in advance try me.
instead of converting in join have executed query , resultset simple resultset type work paginator class of phalcon.
// base model $bm = new basemodel(); // execute query $rs = new phalcon\mvc\model\resultset\simple(null, $bm, $bm->getreadconnection()->query($sql));
Comments
Post a Comment