Reputation: 344
before anything, please understand i'm a complete codeigniter noob, and know only enough php to get by. But understand it really well if it's explained very well.
I'm building a web app, installed sparks, then ion_auth which is up and running correctly.
Users can sign up, yada yada yada.
Now i'm trying to create my first model which is 'project'.
This is where I get lost...
here is my Project Model, I want to use php-activerecord and have relationships between my users and projects.
class Project extends ActiveRecord\Model {
public function __construct() {
parent::__construct();
$this->load->database();
}
static $belongs_to = array(
array('user')
);
public function projects() {}
}
Since Ion_Auth is a spark and sitting in
-sparks
--ion_auth
---2.3.2
----models
-----ion_auth_model.php
here is the code for the top of that class
class Ion_auth_model extends CI_Model {
But when I change 'extends CI_Model' to the 'extends Activerecord\model' everything breaks.
how do I get this working so that I can have $has_many and $belongs_to in the appropriate models?
been on this for a couple of hours now and its finally starting to get to me..
Any help is GREATLY appreciated.
Upvotes: 0
Views: 239
Reputation: 3118
As per the Codeigniter's Model documentation your model should extend CI_Model, load active record in your model like $this->load->database();
or add in autoload and use it like $this->db->query('select * from tablename');
Upvotes: 1