Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Use ORM default id as admin_id
  • I already viewed this link http://fuelphp.com/forums/discussion/13255/primary-keys-with-different-id-name
    but not found the answer.
    I want to know it's possible or not to use ORM default id as my custom id (admin_id).
    When I run this command in oil console "Model_Admin_Account::find(2)->to_array();" I know ORM find search 2 by id. I want to use it with my own admin_id.
    If there have to change in ORM configure, please could you tell me how to do?

    My Model is in below, I want to remove 'id'.

    <?php

    class Model_Admin_Account extends \Orm\Model
    {
        protected static $_properties = array(
            'id',
            'admin_id',
            'admin_code',
            'super_admin_code',
            'admin_name',
            'admin_password',
            'admin_is_enabled',
            'admin_is_delete',
            'admin_delete_date',
            'admin_create_date',
            'admin_update_date',
        );
       
  • philipptempelphilipptempel
    Accepted Answer
    Set the $_primary_key property off your model manually to

    protected static $_primary_key = ['admin_id'];

    (Note, it has to be an array!)

    Also mentioned here in the docs: http://fuelphp.com/dev-docs/packages/orm/creating_models.html#/primary_key
  • That is pretty work. You saved my time. Thank you very much. :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion