Welcome Guest, Not a member yet? Register   Sign In
Using alias in active record
#1

[eluser]Rey Philip Regis[/eluser]
Hi guys,

I need your help, I need to know how to use alias in active record.

SQL is this: I want that the key of the array is "name" just what I specified in the alias not the key "description".

Code:
select
     hpideterminanttype.description as `name`
   from
     hpideterminanttype
   where
     hpideterminanttype.stat = '1'

   Output should be:
   array(
            [0] => array
                       (
                         [name] => 'ONSET'
                       )
            [1] => array
                       (
                         [name] => 'LOCATION'
                       )  
         )
    
     Not:
     array(
            [0] => array
                       (
                         [description] => 'ONSET'
                       )
            [1] => array
                       (
                         [description] => 'LOCATION'
                       )  
         )
Thanks in advance......
#2

[eluser]Phil Sturgeon[/eluser]
Alias in select like so:

Code:
$this->db->select('hpideterminanttype.description as `name`', FALSE);

To alias a table you must use the following:

Code:
$this->db->from('tablename t1');
$query = $this->db->get();
#3

[eluser]Rey Philip Regis[/eluser]
thnks for the reply..




Theme © iAndrew 2016 - Forum software by © MyBB