Skip to main content
Clarified the title, clarified the question, new tagging
Source Link

getListQuery Confusion about using two select() function and select questionmethod calls in one query

I have a question about this line of codeam using Joomla's JDatabaseQuery methods to select some columns from two joined tables, see belowbut I don't understand something about the following snippet.

    //Initialize variables.
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    
    //Create the base select statement.
    $query->select('a.id as id, a.greeting as greeting, a.published as published')
      ->from($db->quoteName('#__diolegend','a'));
    
    //Join over the categories.
    $query->select($db->quoteName('c.title' ,'category_title'))
      ->join('LEFT',$db->quoteName('#__categories','c')
        . ' ON c.id =a.catid');
    $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__categories','c')
        . ' ON c.id =a.catid');

See in the 2nd select(), there is no mention of a.catid?

How can it be possible to still retrieve a.catid, wea.catid? We haven't selectselected it from anywhere...

Thank you everybody

getListQuery() function and select question

I have a question about this line of code, see below

    //Initialize variables.
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    
    //Create the base select statement.
    $query->select('a.id as id, a.greeting as greeting, a.published as published')->from($db->quoteName('#__diolegend','a'));
    
    //Join over the categories.
    $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__categories','c')
        . ' ON c.id =a.catid');
    $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__categories','c')
        . ' ON c.id =a.catid');

How can it be possible to still retrieve a.catid, we haven't select from anywhere...

Thank you everybody

Confusion about using two select() method calls in one query

I am using Joomla's JDatabaseQuery methods to select some columns from two joined tables, but I don't understand something about the following snippet.

//Initialize variables.
$db = JFactory::getDbo();
$query = $db->getQuery(true);

//Create the base select statement.
$query->select('a.id as id, a.greeting as greeting, a.published as published')
      ->from($db->quoteName('#__diolegend','a'));

//Join over the categories.
$query->select($db->quoteName('c.title' ,'category_title'))
      ->join('LEFT',$db->quoteName('#__categories','c') . ' ON c.id =a.catid');

See in the 2nd select(), there is no mention of a.catid?

How can it be possible to retrieve a.catid? We haven't selected it from anywhere.

edit $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__categories','c') . ' ON c.id =a.catid');
Source Link

I have a question about this line of code, see below

    //Initialize variables.
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    
    //Create the base select statement.
    $query->select('a.id as id, a.greeting as greeting, a.published as published')->from($db->quoteName('#__diolegend','a'));
    
    //Join over the categories.
    $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__diolegend''#__categories','c')
        . ' ON c.id =a.catid');
    $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__diolegend''#__categories','c')
        . ' ON c.id =a.catid');

How can it be possible to still retrieve a.catid, we haven't select from anywhere...

Thank you everybody

I have a question about this line of code, see below

    //Initialize variables.
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    
    //Create the base select statement.
    $query->select('a.id as id, a.greeting as greeting, a.published as published')->from($db->quoteName('#__diolegend','a'));
    
    //Join over the categories.
    $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__diolegend','c')
        . ' ON c.id =a.catid');
   $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__diolegend','c')
        . ' ON c.id =a.catid');

How can it be possible to still retrieve a.catid, we haven't select from anywhere...

Thank you everybody

I have a question about this line of code, see below

    //Initialize variables.
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    
    //Create the base select statement.
    $query->select('a.id as id, a.greeting as greeting, a.published as published')->from($db->quoteName('#__diolegend','a'));
    
    //Join over the categories.
    $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__categories','c')
        . ' ON c.id =a.catid');
    $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__categories','c')
        . ' ON c.id =a.catid');

How can it be possible to still retrieve a.catid, we haven't select from anywhere...

Thank you everybody

Source Link

getListQuery() function and select question

I have a question about this line of code, see below

    //Initialize variables.
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    
    //Create the base select statement.
    $query->select('a.id as id, a.greeting as greeting, a.published as published')->from($db->quoteName('#__diolegend','a'));
    
    //Join over the categories.
    $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__diolegend','c')
        . ' ON c.id =a.catid');
   $query->select($db->quoteName('c.title' ,'category_title'))->join('LEFT',$db->quoteName('#__diolegend','c')
        . ' ON c.id =a.catid');

How can it be possible to still retrieve a.catid, we haven't select from anywhere...

Thank you everybody