http://kohanaframework.org/3.2/guide/orm/relationshipsによる
2 つのモデルがあるとします。with 1 User : Many Posts 関係。選択したユーザーのすべての投稿を削除するにはどうすればよいですか?
モデル_ユーザー
protected $_has_many = array('posts' => array());
モデル_支柱
protected $_belongs_to = array(
'user' => array(
'foreign_key' => 'author_id',
),
);
試し$user->posts->delete()
ましたが、うまくいきません。
編集:
このケースでは実際には機能せず、関係remove()
にのみ使用できることを追加したいだけです。has_many 'through'
* @param string $alias Alias of the has_many "through" relationship
* @param mixed $far_keys Related model, primary key, or an array of primary keys
* @return ORM
*/
public function remove($alias, $far_keys = NULL)
orm/classes/kohana/orm.php