Search code examples
phpoopkohanakohana-3kohana-orm

How do I set columns/members in Kohana ORM v3


class Model_User extends ORM {
  // columns: UserID, Name
  // public $Name ; // this didn't work
}

Currently I create an object: $user = new Model_User() ; and access columns like:

 $user->Name = 'My Name';

I'd like to have my IDE show me all the columns in the data model to avoid misspellings and to now right away what fields I can use.

How do I update my model to give my IDE the list of possible columns/properties? I tried adding the properties to the class but that broke the ORM() and no longer allowed saving. I must have overridden some base class property that gets set after reading in the column names from the database.


Solution

  • Use phpDoc's @property tag:

    /**
       @property  string   Name     username
       @property  int      UserID   user ID (primary key)
     */
    class Model_User extends ORM {
    // ...
    }