Base_module_model or Base_module_record

edited August 2012 in Modules
I’ve read through the modules tutorial http://www.getfuelcms.com/user_guide/modules/simple but I’m not sure when to use the class extending Base_module_record

Using the authors model as an example I have

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Authors_model extends Base_module_model {

// Required fields
public $required = array('name', 'email');

function __construct()
{
parent::__construct('authors');
}

function form_fields($values = array())
{
$fields = parent::form_fields($values);

$upload_path = assets_server_path('authors/', 'images');
$fields['avatar_upload'] = array('type' => 'file', 'upload_path' => $upload_path, 'overwrite' => TRUE);
$fields['published']['order'] = 1000;
return $fields;
}

}

class Author_model extends Base_module_record {

public function get_avatar_image()
{
return 'imageavatar).'" />';
}

}

In my controller I then load the authors model and want to get the details of a specific author with id of 1

<?php

class Authors extends CI_Controller {

function __construct()
{
parent::__construct();
}

function index()
{

$this->load->model('authors_model');

// Get author with id of 1

}

}

Do I need to add a function to Author_model or Authors_model?

Comments

Sign In or Register to comment.