• 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' => ''
            )
        );
  • 相关阅读:
    寒假补习记录_4
    寒假补习记录_3
    寒假补习记录_2
    寒假补习记录_1
    公文流转系统编程
    Javaweb编程
    转:在静态方法中访问类的实例成员
    Java字段初始化规律
    原码,反码,补码浅谈
    java第二节课课后
  • 原文地址:https://www.cnblogs.com/linksgo2011/p/2988712.html
Copyright © 2020-2023  润新知