Yii Framework Forum: [EXTENSION] CSaveRelationsBehavior - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] CSaveRelationsBehavior CSaveRelationsBehavior Save HasMany and ManyMany relational active rec Rate Topic: ***** 1 Votes

#41 User is offline   Stephen51 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 09-May 12

Posted 30 May 2012 - 02:28 PM

Alban,

I have the same problem as Bitmatrix above (post dated Posted 20 November 2010 - 07:52 AM).

Do you have any ideas how I can get around the problem?

Thanks!
0

#42 User is offline   thiagovidal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 17-February 10
  • Location:Brazil, São Paulo

Posted 14 February 2013 - 01:31 PM

Hey @juban. How are you? I'm using your extension and it's working very well. I want to know how to ajax validate my model with relations? Have you had this issue? Can you help me?

Thanks in advance.

TOV
0

#43 User is offline   Neil Kar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 09-July 13

Posted 25 July 2013 - 02:04 AM

Just tried out the demo 1.1 and it works fantastic! Amazing extension!
0

#44 User is offline   joemiller 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 08-August 13

Posted 09 August 2013 - 03:18 PM

Hi, and thanks for posting this excellent extension, it's been really useful. I've found a bug in the code when using it with relations that are declared with 'through'. I've submitted a bug report on Google code, but I wasn't sure if you get those, so I'm taking the libery of posting here as well. My apologies if I'm duplicating issues!
Copy of the bug report:
What steps will reproduce the problem?
Set-up: three tables;
Book - A list of books
Author - A list of authors of those books. A book can have many authors, and authors can write many books, so a joining table is used.
BookAuthors - composite primary key consisting of author_id and book_id
1.Declare relations as follows:
In model 'Book'
public function relations() {
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'bookAuthors' => array(self::HAS_MANY, 'BookAuthors', 'book_id'),
'authors' => array(self::HAS_MANY, 'Author', 'author_id', 'through' => 'bookAuthors'),
);
}
2.Try to delete a book
3.

What is the expected output? What do you see instead?
I would expect the related records in BookAuthors to be deleted only. I don't want authors to be deleted, as they may have other books they have written.
Instead, the behavior goes through each relation, and throws an error on finding the authors relation. It reports that it cannot find the column 'author_id' in table 'author'

What version of the product are you using? On what operating system?
v1.0.3 on Linux Ubuntu


Please provide any additional information below.
I've been able to make a temporary fix by altering the following lines in CSaveRElationsBehavior.php:
Lines 385 - 391 are now
if (!$activeRelation->through) {
// HasMany & HasOne relation : delete related records
$relatedRecord = new $relationClassName;
$criteria = new CDbCriteria;
$criteria->addColumnCondition(array($relationForeignKey => $model->primaryKey));
$relatedRecord->deleteAll($criteria);
}
0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users