Welcome Guest, Not a member yet? Register   Sign In
How to use variable in Active record SELECT
#1

[eluser]shinokada[/eluser]
I need to use a variable in $this->db->select();

Something like this,

$this->db->select('$tableid,name');

Code:
function findOrphans($segment, $id, $db_table){
     $tablename = explode("-", $db_table);
    $tableid = $tablename[1]."_id";
    
    $data = array();
     $this->db->select('$tableid,name');

But I am not sure if I can.

Can anyone tell me how to please?
#2

[eluser]gigas10[/eluser]
I don't believe you want to put single quotes around a variable name in active record. So:
Code:
[b]$this->db->select($tableid,'name');[/b]
#3

[eluser]wowdezign[/eluser]
Did you try this?
Code:
function findOrphans($segment, $id, $db_table){
     $tablename = explode("-", $db_table);
    $tableid = $tablename[1]."_id";
    
    $data = array();
     $this->db->select($tableid.',name');




Theme © iAndrew 2016 - Forum software by © MyBB