Kamus Yii by sonsonz.wordpress.com

Fungsi Pencarian

// find the first row satisfying the specified condition
$post=Post::model()->find($condition,$params);
// find the row with the specified primary key
$post=Post::model()->findByPk($postID,$condition,$params);
// find the row with the specified attribute values
$post=Post::model()->findByAttributes($attributes,$condition,$params);
// find the first row using the specified SQL statement
$post=Post::model()->findBySql($sql,$params);

Fungsi Filter

- protected (before|after)(Delete|Save|Find)() ?
- $this->isNewRecord ?
- protected afterConstruct()

Fungsi Relasi Database

'VarName'=>array('RelationType', 'ClassName', 'ForeignKey', ...additional options)
BELONGS_TO? 'author'=>array(self::BELONGS_TO, 'User', 'author_id'),
HAS_MANY?
HAS_ONE?
BELONGS_TO? MANY_MANY: 'relation_a_b' => array(self::MANY_MANY, 'B', A_B('a_id','b_id'),
'relation_b_a' => array(self::MANY_MANY, 'A', A_B('b_id','a_id'), ?
STAT?
load by attribute:$model->relationName?
with()?

CDbCriteria

    $criteria=new CDbCriteria;
    $post=Post::model()->find($criteria);
    select: $criteria->select='title';
    condition: $criteria->condition='postID=:postID';
    params: $criteria->params=array(':postID'=>10); 
    on: 
    order: 
    with: 
    joinType: 
    alias: 
    together: 
    join: 
    group:
    ?
    having: ?
    index: ?
    limit: ?
    offset: ?

Share this:

By dtriyanto Posted in Santai

Leave a comment