Mahdi-563
دوشنبه 19 فروردین 1392, 15:34 عصر
سلام دوستان
من یک مدل دارم که چند نوع رابطه چند به یک، یک به یک و ... داره حال اینکه من توی ایجاد و حدف مشکلی ندارم ولی توی آپدیت با متد saveAssociated مشکل دارم
جالب اینکه با متد save فقط روابط چند به یک رو ذخیره می کنه ولی یک به یک را ذخیره نمی کنه
ممنون
اینم مدلم
public $hasOne = array(
'Description' => array(
'className' => 'Description',
'dependent' => true,
'unique' => true,
),
'Tag' => array(
'className' => 'Tag',
'dependent' => true,
'unique' => true,
),
);
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'Language' => array(
'className' => 'Language',
'foreignKey' => 'language_id',
'conditions' => '',
'fields' => '',
'order' => '',
),
);
/**
* hasMany associations
*
* @var array
*/
public $hasMany = array(
'ProductImage' => array(
'className' => 'ProductImage',
'foreignKey' => 'product_id',
'conditions' => '',
'fields' => '',
'order' => 'sort_order DESC',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
, 'dependent' => true),
'ProductOption' => array(
'className' => 'ProductOption',
'foreignKey' => 'product_id',
'conditions' => '',
'fields' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
, 'dependent' => true
),
'ProductSpecial' => array(
'className' => 'ProductSpecial',
'foreignKey' => 'product_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
);
/**
* hasAndBelongsToMany associations
*
* @var array
*/
public $hasAndBelongsToMany = array(
'Relate' => array(
'className' => 'Product',
'joinTable' => 'products_relate',
'foreignKey' => 'product_id',
'associationForeignKey' => 'relate_id',
// 'unique' => 'keepExisting',
'dependent' => true,
),
'productStores' => array(
'className' => 'productStores',
'joinTable' => 'product_stores',
'foreignKey' => 'product_id',
'associationForeignKey' => 'store_id',
// 'unique' => 'keepExisting',
'dependent' => true
),
'attribute' => array(
'className' => 'attribute',
'joinTable' => 'product_attributes',
'foreignKey' => 'product_id',
'associationForeignKey' => 'attribute_id',
// 'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => 'sort_order DESC',
'dependent' => true
),
'Category' => array(
'className' => 'Category',
'joinTable' => 'product_categories',
'foreignKey' => 'product_id',
'associationForeignKey' => 'category_id',
// 'unique' => 'keepExisting',
'conditions' => '',
'fields' => 'name',
'dependent' => true
),
);
من یک مدل دارم که چند نوع رابطه چند به یک، یک به یک و ... داره حال اینکه من توی ایجاد و حدف مشکلی ندارم ولی توی آپدیت با متد saveAssociated مشکل دارم
جالب اینکه با متد save فقط روابط چند به یک رو ذخیره می کنه ولی یک به یک را ذخیره نمی کنه
ممنون
اینم مدلم
public $hasOne = array(
'Description' => array(
'className' => 'Description',
'dependent' => true,
'unique' => true,
),
'Tag' => array(
'className' => 'Tag',
'dependent' => true,
'unique' => true,
),
);
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'Language' => array(
'className' => 'Language',
'foreignKey' => 'language_id',
'conditions' => '',
'fields' => '',
'order' => '',
),
);
/**
* hasMany associations
*
* @var array
*/
public $hasMany = array(
'ProductImage' => array(
'className' => 'ProductImage',
'foreignKey' => 'product_id',
'conditions' => '',
'fields' => '',
'order' => 'sort_order DESC',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
, 'dependent' => true),
'ProductOption' => array(
'className' => 'ProductOption',
'foreignKey' => 'product_id',
'conditions' => '',
'fields' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
, 'dependent' => true
),
'ProductSpecial' => array(
'className' => 'ProductSpecial',
'foreignKey' => 'product_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
);
/**
* hasAndBelongsToMany associations
*
* @var array
*/
public $hasAndBelongsToMany = array(
'Relate' => array(
'className' => 'Product',
'joinTable' => 'products_relate',
'foreignKey' => 'product_id',
'associationForeignKey' => 'relate_id',
// 'unique' => 'keepExisting',
'dependent' => true,
),
'productStores' => array(
'className' => 'productStores',
'joinTable' => 'product_stores',
'foreignKey' => 'product_id',
'associationForeignKey' => 'store_id',
// 'unique' => 'keepExisting',
'dependent' => true
),
'attribute' => array(
'className' => 'attribute',
'joinTable' => 'product_attributes',
'foreignKey' => 'product_id',
'associationForeignKey' => 'attribute_id',
// 'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => 'sort_order DESC',
'dependent' => true
),
'Category' => array(
'className' => 'Category',
'joinTable' => 'product_categories',
'foreignKey' => 'product_id',
'associationForeignKey' => 'category_id',
// 'unique' => 'keepExisting',
'conditions' => '',
'fields' => 'name',
'dependent' => true
),
);