k1low/has_no

CakePHP 的简单绑定模型实践插件。

资助包维护!
k1LoW

安装数: 4,036

依赖项: 1

建议者: 0

安全: 0

星标: 7

关注者: 2

分支: 0

开放问题: 0

类型:cakephp-plugin

3.0.1 2015-10-30 03:07 UTC

This package is auto-updated.

Last update: 2024-09-06 09:12:28 UTC


README

此插件支持以下绑定模型实践。

在模型文件中烘焙并编写绑定属性。全部解除绑定模型()。绑定模型()您想要的。

功能

  • 通过 Model::belongsTo, Model::hasOne, Model::hasMany, Model::hasAndBelongsToMany 解除模型的所有绑定模型()。
  • 通过 Model::belongsTo, Model::hasOne, Model::hasMany, Model::hasAndBelongsToMany 提供 has(), hasAll() 简单绑定模型方法。

!!!!!注意!!!!!

HasNo >= 3.x

基于 Containable

HasNo 2.x

基于属性修改

用法

将以下代码添加到您想要解除所有绑定模型的任何模型中(例如 Post 模型)。

<?php
class Post extends Model {
    public $actsAs = array('HasNo.HasNo');

    public $hasMany = array(
        'Comment' => array(
            'className' => 'Comment',
            'foreignKey' => 'post_id',
            'dependent' => false,
        )
    );

    public $hasAndBelongsToMany = array(
        'Tag' => array(
            'className' => 'Tag',
            'joinTable' => 'posts_tags',
            'foreignKey' => 'post_id',
            'associationForeignKey' => 'tag_id',
            'unique' => true,
        )
    );

}

如果您想使用模型的绑定属性,请使用方法 $this->Post->has('Comment')$this->Post->has(array('Comment', 'Tag'))$this->Post->hasAll() .

许可证

MIT 许可证下