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:

  1. id pk
  2. message
  3. group_id
  4. creation_date

post_notifications

  1. id pk
  2. user_id
  3. notify_msg
  4. post_id
  5. 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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -