<?php
/**
 * Class represents records from table aff_banners
 * {autogenerated}
 * @property int $banner_id 
 * @property int $type 
 * @property string $title 
 * @property string $desc 
 * @property int $upload_id 
 * @property int $upload_big_id 
 * @property string $url 
 * @property string $mime 
 * @property int $width 
 * @property int $height 
 * @property int $is_disabled 
 * @see Am_Table
 */
class AffBanner extends Am_Record {

    const TYPE_TEXTLINK = 1;
    const TYPE_BANNER = 2;
    const TYPE_PAGEPEEL = 3;
    const TYPE_LIGHTBOX = 4;
    const TYPE_CUSTOM = 5;

}

class AffBannerTable extends Am_Table {
    protected $_key = 'banner_id';
    protected $_table = '?_aff_banner';
    protected $_recordClass = 'AffBanner';
    
    function findActive(){
        return $this->selectObjects("SELECT * FROM ?_aff_banner WHERE IFNULL(is_disabled,0)=0 ORDER BY IF(sort_order = 0, ~0, sort_order) ASC");
    }
}

