We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29796
    • 91 Posts
    Ok i managed to get info i need, i just want to make it better .. but i don’t know how .. so i have few questions...

    To get data i need i first i used this part of code
    $query = $modx->db->query("
      SELECT c.id, c.pagetitle, tv.value as price
      FROM site_content c
      LEFT JOIN site_tmplvar_contentvalues tv ON c.id = tv.contentid
      WHERE c.id IN ( 25,26,27 )
      AND tv.tmplvarid=2
      AND c.published=1 AND c.deleted=0
      AND c.context_key='$context'
    ");
    


    and it works fine, but then i wanted to do it with xpdo so first i used:
      $cart = $modx->newQuery('modResource');
      $cart->select(array('id','pagetitle','longtitle')); 
      $cart->where(array(
          'id:IN' => array(25,26,27),
          'published' => true,
          'deleted' => false
      ));
      $resources = $modx->getCollection('modResource',$cart);
    


    then i needet also TV, so i did:

      $tv = $modx->newQuery('modTemplateVarResource');  
      $tv->where(array(
        'contentid:IN' => array(25,26,27),
        'tmplvarid' => 2
      ));
      $tvars = $modx->getCollection('modTemplateVarResource',$tv);  
    



    in this way i get all data i need using XPDO.

    My questions are:

    1. How can do it with on query using left join or something similar?
    2. in modResource query i allways get entire array regardless what is in "->select", well select works, and i get values only for selected fields .. but also i get empty values for all other keys ?
    3. in modTemplateVarResource query i tryed to use $tv->select(array(’contentid’,’value’)); and i got an error "The server encountered an internal error or misconfiguration and was unable to complete your request."