Creating an object by primary key
In the documentation the example for getting a record by primary key is:
$foo = $this->examples_model->find_by_key(1);
$foo->bar = 'This is a test';
$foo->save();
In the documentation the find_by_key method returns an array by default and not an object like above. In my code I tried this:
$p = $this->products_model->find_by_key(2, 'object');
$p->title = 'Changed title';
$p->save();
It does return an object, but doesn't inherit any of the functions like save() etc
My model is pretty simple, does anyone know what I'm doing wrong?
class Products_model extends Base_module_model {
function __construct()
{
parent::__construct('products', array('key_field' => 'id'));
}
}
Comments
class Products_model extends Base_module_model { function __construct() { parent::__construct('products', array('key_field' => 'id')); } } class Product_model extends Base_module_record { }
https://github.com/daylightstudio/FUEL-CMS/tree/1.0