Search code examples
fuelphp

FuelPHP requires all tables to have an "id" column?


FuelPHP appears to require and id column (throws errors if an id column doesn't exist)

I this case I would like to use "master_id" which is matching the field name with an external datasource and would like to name the field that way instead.

class Model_User extends Orm\Model
{
    protected static $_table_name = 'user';
     protected static $_properties = array('master_id', 'last_name', 'first_name', 'account','email','ts_lastlogin','ts_create'); 
}

Solution

  • Setting the primary key manually solves the issue:

    class Model_User extends Orm\Model
    {
        protected static $_primary_key = array('master_id');
        protected static $_table_name = 'user';
         protected static $_properties = array('master_id', 'last_name', 'first_name', 'account','email','ts_lastlogin','ts_create'); 
    }