Search code examples
phpcodeigniterselect

codeigniter select as


how doHow do we do select table.value as table_value from table in codeigniter?
The AS part doesnt work because when i try to access the value, this doesnt work:

    $qry_inp =  'select table.value as table_value from table '
    $query = $this->db->query($qry_inp); 

    echo $query->row('table_value ');// this will be empty, but it shouldn`t be

doesn`t matter if its in AR or simple query


Solution

  • Where is that behaviour documented? row doesn't take a column name as a parameter; it optionally takes a row number, and that's it. Access it like any other field:

    echo $query->row()->table_value;