So I am trying to get a specific setting out of the database. And it seems that most of the CodeIgniter DB actions don't work in ExpressionEngine( http://ellislab.com/codeigniter/user-guide/database/results.html)

I am wanting to do something like this:

$facebook_id = $this->EE->db->some_db_function('table_name', array('column_name', 'value'));

And that would create a query like this:

Select column_name FROM table_name WHERE column_name=`value`;

Just in case there is any confusion, here is my actual code currently:

$query = $this->EE->db->get_where( 'fb_photo_settings', array('setting_name' => 'facebook_id') );

But that returns an object and I'm wanting to just run a query that returns just the value.

And it just returns the value in the field, not an object or an array just the value. Is there any way to do this. And if not - how can I use the result() type functions on the link above?


  • 1
    Did you get this sorted out? Commented Jan 15, 2013 at 16:42

1 Answer 1


To get a single value, you want to use the row() method on your $query object:

$query = $this->EE->db->get_where( 'fb_photo_settings', array('setting_name' => 'facebook_id') );
$var = $query->row('my_col');

To get an object with a whole row:

$query = $this->EE->db->get_where( 'fb_photo_settings', array('setting_name' => 'facebook_id') );
$row = $query->result_array();

Always a good idea to check for the existence of results first though:

if($query->num_rows() > 0)
    // do stuff with $query

All of CodeIgniter's Active Record querying methods should work in EE. You can even load Database Forge to create and edit tables via $this->EE->load->dbforge().

  • Just clarified my former answer, as I misinterpreted exactly what you were trying to do. Commented Jan 11, 2013 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.