Help with find_one_by

edited July 2012 in News & Announcements

I have a table called: member_emails.
The table has four fields:

The table's model:
class Member_emails_model extends MY_Model { public $record_class = 'Member_email'; public $foreign_keys = array('member_id' => 'members_model'); function __construct() { parent::__construct('member_emails'); } function _common_query() { $this->db->select('member_emails.*'); $this->db->join('members', 'member_emails.member_id =', 'left'); } } class Member_email_model extends Data_record { }

In my members view I am trying to select the record from the above table for the member I am viewing like this:
$CI->load->model('member_emails_model'); $emails = $CI->member_emails_model->find_one_by_member_id($memberId);

I checked, the the $memberId value does exist in the member_emails table.

I am getting this error:
Fatal error: Cannot use object of type Member_email_model as array in C:\wamp\www\clarenssa\fuel\application\third_party\fuel\Loader.php(298) : eval()'d code on line 60

Why do I get this error?


  • edited 11:19AM
    What are you doing with $emails?

    Looks like you might be trying to do $emails['some_field'] when it's an object so should be using $emails->some_field
  • edited 11:19AM
    Duh.... thanks :)
Sign In or Register to comment.