Now that we have a brief understanding of migrations and Oil, let's put Oil to use. We'll create a model along with their corresponding database table details with the following command:
$ php oil generate model entry name:string slug:string excerpt:text content:text published_at:timestamp
This will create both the model and migration. Let's open the newly created entry.php
model, located at fuel/app/classes/model/
:
<?php class Model_Entry extends \Orm\Model { protected static $_properties = array( 'id', 'name', 'slug', 'excerpt', 'content', 'published_at', 'created_at', 'updated_at', ); protected static $_observers = array( 'Orm\Observer_CreatedAt' => array( 'events' => array('before_insert'), 'mysql_timestamp' => false, ), 'Orm\Observer_UpdatedAt' => array( 'events' => array('before_save'), 'mysql_timestamp' => false...