O'Reilly logo

Learning FuelPHP for Effective PHP Development by Ross Tweedie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Models

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' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required