Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
result index is always primary key value?
  • Hi, I have the following model:
    class Model_CMS extends Orm\Model
    {
    
     /**
      * Table name
      *
      * @var  string
      */
     protected static $_table_name = 'cms';
    
     /**
      * Primary key
      *
      * @var  array
      */
     protected static $_primary_key = array('id');
    
     /**
      * Properties
      *
      * @var  array
      */
     protected static $_properties = array(
      'id'             => array('data_type' => 'int'),
      'parent_id'      => array('data_type' => 'int'),
      'tag'          => array('data_type' => 'varchar'),
      'title'        => array('data_type' => 'varchar'),
      'description'    => array('data_type' => 'varchar'),
      'content'        => array('data_type' => 'text'),
      'sort_order'     => array('data_type' => 'int', 'default' => 999),
      'created_at'     => array('data_type' => 'time_unix'),
      'updated_at'     => array('data_type' => 'time_unix'),
     );
    
     /**
      * Used observers
      *
      * @var  array
      */
     protected static $_observers = array(
      'Orm\\Observer_Typing' => array(
       'events' => array('before_save', 'after_save', 'after_load'),
      ),
      'Orm\\Observer_CreatedAt' => array(
       'events' => array('before_insert')
      ),
            'Orm\\Observer_UpdatedAt' => array(
             'events' => array('before_save')
            ),
            'Orm\\Observer_Slug' => array(
             'events' => array('before_insert'),
             'source' => 'title',
             'property' => 'tag',
         ),
     );
    }
    

    Now I do the following in a controller:
    $menuitems = Model_CMS::find('all', array('order_by' => array('sort_order' => 'asc')));
    

    this gives me a Model_CMS Object result set. But normally the array starts with index 0, but now it starts always with the value of the id field... is this standard in the ORM package? Or am I missing something?
  • Anyone?
  • This is by design: the array index == the id.

Howdy, Stranger!

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

In this Discussion