Location: PHPKode > projects > Alloy PHP Framework > alloyphp-alloy-63bce73/alloy/Plugin/Spot/lib/Spot/tests/Entity/Post.php
<?php
/**
 * Post 
 *
 * @package Spot
 * @link http://spot.os.ly
 */
class Entity_Post extends \Spot\Entity
{
    protected static $_datasource = 'test_posts';

    public static function fields()
    {
        return array(
            'id' => array('type' => 'int', 'primary' => true, 'serial' => true),
            'title' => array('type' => 'string', 'required' => true),
            'body' => array('type' => 'text', 'required' => true),
            'status' => array('type' => 'int', 'default' => 0, 'index' => true),
            'date_created' => array('type' => 'datetime')
        );
    }
    
    public static function relations()
    {
        return array(
            // Each post entity 'hasMany' comment entites
            'comments' => array(
                'type' => 'HasMany',
                'entity' => 'Entity_Post_Comment',
                'where' => array('post_id' => ':entity.id'),
                'order' => array('date_created' => 'ASC')
            )
        );
    }
}
Return current item: Alloy PHP Framework