Model(詳細)

Model(モデル)


  • 主な変数
name : マッピング対象テーブル名を指定する
(デフォルトではクラス名の複数型テーブルにマッピングされる)

  • メソッド



$this->Hoge->cacheQueries = false;

アソシエーション

  • CakePHP では、テーブル間のつながりをアソシエーションで扱います。

  • CakePHP には四種類のアソシエーションがあります
hasOne
hasMany
belongsTo
hasAndBelongsToMany

<?php
class Collective extends AppModel {
   var $name = 'Collective';
   
   var $hasMany =
       array('Post' =>
           array('className' => 'Post',
               'conditions' => 'Post.del_flg = 0',
               'order' => 'Post.last_update_time DESC',
               'limit' => '5',
               'foreignkey' => 'collective_id',
               'dependent' => true,
               'exclusive' => false,
               'finderQuery' => ''
       )
   );
   
}
?>

**コールバック
beforeFind,afterFind
;
beforeSave,afterSave
;
最終更新:2007年09月02日 14:39