Yii Framework Forum: Insert A New Record Via Model Instead Of Controller - Yii Framework Forum

Jump to content

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

Insert A New Record Via Model Instead Of Controller Rate Topic: -----

#1 User is offline   Anonymous Joe 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 31-August 12

Posted 24 December 2012 - 10:33 PM

Hi, does anyone have any guide on how to insert a new record via model instead of controller?

Thanks.
0

#2 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 25 December 2012 - 02:09 AM

View PostAnonymous Joe, on 24 December 2012 - 10:33 PM, said:

Hi, does anyone have any guide on how to insert a new record via model instead of controller?

Thanks.



Could you please explain a bit more please.

Well if you dont want to write a code for Insert record in controller then you can define a method in model and call that method in controller to perform this task.
CodeSutra
0

#3 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,311
  • Joined: 21-February 11
  • Location:Greece

Posted 25 December 2012 - 04:11 AM

Insert, Update and Delete actions In Model have sense only on events of Model AR.

So if you want to insert a new record of a model B, after of save Model A then you can use the event AfterSave() in model A.

check also
http://www.yiiframew...eRecordBehavior
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
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