Yii Framework Forum: Yii just igore some codes - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii just igore some codes Rate Topic: -----

#1 User is offline   kevin2010 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 17-January 10

Posted 06 March 2010 - 01:39 AM

hi, all

i have this action in Controller_photos :


$model=new Photos;
$photocate = new Photocate;
$photocate->title='test';
$photocate->save();
$model->photocate_id=$photocate->id;
$model->save()

no errors after running.

i checked the database, i can see one new record in table_photos, nothing is in table_photocate.

really strange, Yii just igore these codes:

$photocate = new Photocate;
$photocate->title=$event->title;
$photocate->save();

can someone help me, thanks!
0

#2 User is offline   jayrulez 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 348
  • Joined: 29-July 09

Posted 06 March 2010 - 01:43 AM

View Postkevin2010, on 06 March 2010 - 01:39 AM, said:

hi, all

i have this action in Controller_photos :


$model=new Photos;
$photocate = new Photocate;
$photocate->title='test';
$photocate->save();
$model->photocate_id=$photocate->id;
$model->save()

no errors after running.

i checked the database, i can see one new record in table_photos, nothing is in table_photocate.

really strange, Yii just igore these codes:

$photocate = new Photocate;
$photocate->title=$event->title;
$photocate->save();

can someone help me, thanks!



What is the relationship between your models. Are your tables innodb with constraints?

give more details. You may tre ->save(false); to avoid validation if you're just testing
php:
foreach(array('cat', 'dog', 'cow') as $animal) echo $animal."\n";

python:
[(animal, print(animal)) for animal in ['cat', 'dog', 'cow']]

ruby:
['cat', 'dog', 'cow'].each {|animal| puts animal}


You say Tomato, I say Tomato.
0

#3 User is offline   kevin2010 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 17-January 10

Posted 06 March 2010 - 04:13 AM

View Postjayrulez, on 06 March 2010 - 01:43 AM, said:

What is the relationship between your models. Are your tables innodb with constraints?

give more details. You may tre ->save(false); to avoid validation if you're just testing


thanks very much.

it is caused by a field with not null propertity.

it is very good to know save(false) can disnable verification.
0

Share this topic:


Page 1 of 1
  • 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