티스토리 뷰

Jelly Module 사용하기


Jelly Class

- meta
- field
- model
- validation
- event
- collection
- builder
- behavior

 기본 사용 방법

jelly Model 의 정의


class Model_Board_Old_Article extends Jelly_Model
{
    public static function initialize(Jelly_Meta $meta)
    {
        $meta->table("ha_board")->fields(array(
            'b_no' => Jelly::field('primary'),
            'b_group_no' => Jelly::field('integer'),
            'b_depth_no' => Jelly::field('integer', array(
        		'default' => 0
             )),
            'b_order_no' => Jelly::field('integer', array(
        		'default' => 0
             )),
            'b_subject' => Jelly::field('string'),
            'b_bc_id' => Jelly::field('integer'),
            'b_ca_id' => Jelly::field('integer', array(
        		'default' => 1
             )),
            'b_deleted' => Jelly::field('string', array(
        		'default' => 'N'
             )),
            'b_secreted' => Jelly::field('string', array(
        		'default' => 'N'
             )),
            'b_client_ip' => Jelly::field('string', array(
        		'default' => $_SERVER['REMOTE_ADDR']
             )),
            'b_content' => Jelly::field('text'),
        	'b_created' => Jelly::field('timestamp', array(
        		'auto_now_create' => TRUE
			)),
			'b_updated' => Jelly::field('timestamp', array(
				'auto_now_update' => TRUE
			)),
        ));
    }

    public function totalCount()
    {
        return Jelly::query($this)->select()->count();
    }

    public function getTopRecod( $startNum )
    {
        $aData = jelly::query($this)->select_column(array("b_group_no", "b_order_no"))->order_by("b_group_no", "asc")->order_by("b_order_no", "asc")->offset($startNum)->limit(1)->as_assoc()->select();
        return array( $aData['b_group_no'], $aData['b_order_no']);
    }
}
$result = Jelly::query('Board_Old_Article')->select_column(array('min("b_group_no") as group_min'))->as_assoc()->select()->current();
댓글
댓글쓰기 폼