zoukankan      html  css  js  c++  java
  • cake模型笔记

    RelationshipAssociation TypeExample
    one to one hasOne A user has one profile.
    one to many hasMany A user can have multiple recipes.
    many to one belongsTo Many recipes belong to a user.
    many to many hasAndBelongsToMany Recipes have, and belong to many ingredients.

    四种关联关系。

    一个例子

        /**
         * hasOne associations
         *
         * @var array
         */
        public $hasOne = array(
            'Engine' => array(
                'className' => 'Engine',
                'foreignKey' => 'user_id',
                'conditions' => '',
                'fields' => '',
                'order' => ''
            ),
            'TbAppkey' => array(
                'className' => 'TbAppkey',
                'foreignKey' => 'user_id',
                'conditions' => '',
                'fields' => '',
                'order' => ''
            ),
            'UserAccount' => array(
                'className' => 'UserAccount',
                'foreignKey' => 'user_id',
                'conditions' => '',
                'fields' => '',
                'order' => ''
            )
        );
    
        /**
         * belongsTo associations
         *
         * @var array
         */
        public $belongsTo = array(
            'UserGroup' => array(
                'className' => 'UserGroup',
                'foreignKey' => 'user_group_id',
                'conditions' => '',
                'fields' => '',
                'order' => '',
                'type' => 'inner'
            ),
            'Domain' => array(
                'className' => 'Engine',
                'foreignKey' => 'domain_id',
                'dependent' => false,
                'conditions' => '',
                'fields' => '',
                'order' => '',
                'limit' => '',
                'offset' => '',
                'exclusive' => '',
                'finderQuery' => '',
                'counterQuery' => '',
                'type' => 'inner'
            )
        );
    
        /**
         * hasMany associations
         *
         * @var array
         */
        public $hasMany = array(
            'Merchant' => array(
                'className' => 'Merchant',
                'foreignKey' => 'user_id',
                'dependent' => false,
                'conditions' => '',
                'fields' => '',
                'order' => '',
                'limit' => '',
                'offset' => '',
                'exclusive' => '',
                'finderQuery' => '',
                'counterQuery' => ''
            ),
            'UserAccessPlatform' => array(
                'className' => 'UserAccessPlatform',
                'foreignKey' => 'user_id',
                'dependent' => false,
                'conditions' => '',
                'fields' => '',
                'order' => '',
                'limit' => '',
                'offset' => '',
                'exclusive' => '',
                'finderQuery' => '',
                'counterQuery' => ''
            )
        );
  • 相关阅读:
    js定时跳转
    MySQL跨表更新字段 工作记录
    windows下安装phpcms html/ 文件夹不可写的一种错误以及解决方法
    linux清理僵尸进程
    JQuery实现隔行变色和突出显示当前行 效果
    windows下配置lamp环境(4)---安装MySQL数据库5.6
    windows下配置lamp环境(5)---配置MySQL5.6
    windows下配置lamp环境(3)---配置PHP5.4
    windows下配置lamp环境(0)---软件获取
    windows下配置lamp环境(2)---配置Apache服务器2.2.25
  • 原文地址:https://www.cnblogs.com/linksgo2011/p/2988712.html
Copyright © 2011-2022 走看看