Please help me understand Custom Record

edited March 2014 in News & Announcements
I'm new to FuelCMS and i'm trying to use functions such as lazy_load in my custom record, but not having much.
I basically have an 'email' model that has a foreign key pointing to an 'event' model. I want to make it so that when I grab the data for email it automatically does the join and returns the event obj too.

My code model below:

class Emails_model extends Base_module_model {

public $foreign_keys = array(
'event_id' => array('webcast' => 'events_model'),
'type_id' => array('webcast' => 'emailtypes_model')

function __construct()

class Email_model extends Base_module_record {

function get_email()
$email = $this->lazy_load(array('event_id' => 3), 'events_model', FALSE);
return $email;


And then in my public controller I have:
public function auto_send()
$this->load->module_model('webcast', 'emails_model', 'emailsModel');

$data = $this->emailsModel->get_email();


Though this doesn't work. How do I actually use the Record Class? How do I load a single record and how do I make it so that it automatically loads the events when I get all emails?



  • edited 8:44PM
    The result is on the record you must first get a record object. Below is an example of retrieving an object with the ID of 3 and then getting that records email address:
    // get the record first $record = $this->emailsModel->find_one(array('id' => 3)); // next get the email object that is lazy loaded on the record $email_object = $record->email; // display all the properties of that email object print_r($email_object->values();
  • edited 8:44PM
    Awesome, thanks a lot!
  • edited 8:44PM
    I'm just wondering how I can do a WHERE OR in fuelcms?

    $record = $this->find_all_array(array(
    'event_date >=' => date('Y-m-d'), 'OR broadcasting' => 'Yes'), 'event_date', 1);

    I can't see anything in the docs about it
  • edited 8:44PM
    You can use normal active record:
Sign In or Register to comment.