Please help me understand Custom Record
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()
{
parent::__construct('emails');
}
}
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();
print_r($data);
}
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?
Thanks!
Comments
// 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();
$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
$this->db->or_where....