Yii Framework Forum: Create New Record Ketika Update - Yii Framework Forum

Jump to content

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

Create New Record Ketika Update Rate Topic: -----

#1 User is offline   fajar aji 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 17-July 12
  • Location:Jakarta

Posted 11 September 2012 - 11:45 PM

agan-agan yang jenius, ane mau tanya ni.

kira-kira script nya gimana ya, kalau kondisinya kaya gini:
"Ketika ane update record di Tabel A, otomatis data yang terupdate tadi jadi new reccord di Tabel B".

ada referensi gak gan?
0

#2 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 332
  • Joined: 10-November 10

Posted 12 September 2012 - 08:56 AM

View Postfajar aji, on 11 September 2012 - 11:45 PM, said:

kira-kira script nya gimana ya, kalau kondisinya kaya gini:
"Ketika ane update record di Tabel A, otomatis data yang terupdate tadi jadi new reccord di Tabel B".


Agan bisa tambah event afterSave di model untuk Tabel A. Mungkin kurang lebih seperti ini:

public function afterSave()
{		
   // cek mode update record
   if (!$this->isNewRecord)
   {
      $model = new TabelB;
      ... (isi nilai atribut model)

      $model->save();
   }

   return parent::afterSave();
}



View Postfajar aji, on 11 September 2012 - 11:45 PM, said:

ada referensi gak gan?


CActiveRecord
Fipick - Find and pick recommendations
0

#3 User is offline   fajar aji 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 17-July 12
  • Location:Jakarta

Posted 12 September 2012 - 09:18 PM

View Postrei, on 12 September 2012 - 08:56 AM, said:

Agan bisa tambah event afterSave di model untuk Tabel A. Mungkin kurang lebih seperti ini:

public function afterSave()
{		
   // cek mode update record
   if (!$this->isNewRecord)
   {
      $model = new TabelB;
      ... (isi nilai atribut model)

      $model->save();
   }

   return parent::afterSave();
}





CActiveRecord



Mantap gan.....Terima kasih.... ;D
0

#4 User is offline   mbahsomo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 29-March 10

Posted 12 September 2012 - 11:32 PM

Atau bisa di hajar pake trigger mas.
Sugik Puja Kusuma [mbahsomo]
http://sugik.do-event.com
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