Welcome Guest, Not a member yet? Register   Sign In
Model objects linked directly to db tables?

I would like to treat my models as objects that are directly linked to database.

So I could something like this in my controllers:

//To save a new password
$this->user->password = 'new_password';

Is there a library out there that would do something like this for me?



You can either go for a lightweight MY_Model solution that your models can extend. Jamie Rumbelow created a good one.

If you're looking for more advanced features like for example relations (so you can easily fetch all groups related to a user for example), you need to look at an ORM.

Search here and you'll probably find a few...

I definitely want to be able to work with relationships between the models.

Any recommended ORM library i should look into?

You'll find the one I would recommend in my signature. But you could argue I'm biased. Wink

I'm trying to use DataMapper, and have followed the setup instructions, but I'm getting "Table 'my_table.DataMappers' doesn't exist"

My model looks like this:

class user extends DataMapper {
var $table = 'user';

function __contruct () {

Could it be that DataMapper doesn't work with the most recent CI?

Check your construct spelling.

As long as you have installed the bootstrap in your index.php, Datamapper (the latest version) works fine with CI 2.1.

There are issues with the 'reactor' version, due to large changes in the core, so that is not supported at the moment. I'm waiting until that stabilizes before I start working on that issue.

Theme © iAndrew 2016 - Forum software by © MyBB