Welcome Guest, Not a member yet? Register   Sign In
Using array with $this->db->select() possible?
#1

[eluser]umbongo[/eluser]
I have eg. $options=array('user_id','email'...)

What is the easiest way to use this with $this->db->select()??

ie i would like $this->db->select($options) but this doesn't seem to produce $this->db->select('user_id, email...') as i would have expected ??
#2

[eluser]stuffradio[/eluser]
I don't know, but it's just as easy if not easier to do

Code:
$this->db->select('user_id, email');
#3

[eluser]umbongo[/eluser]
note 'eg.'. I have an array, which is longer than above, and used otherwise, and would like to re-use it in $this->db->select.
#4

[eluser]cideveloper[/eluser]
This should work

Code:
$options=array('user_id','email','name','address');

$this->db->select(implode(",", $options));
#5

[eluser]Cristian Gilè[/eluser]
Code:
$options = array('user_id','email');
$fields = implode(',',$options);
$this->db->select($fields);

Cristian Gilè




Theme © iAndrew 2016 - Forum software by © MyBB