Yii Framework Forum: Bagaimana Menerapkan After/BeforeDelete - Yii Framework Forum

Jump to content

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

Bagaimana Menerapkan After/BeforeDelete AfterDelete and BeforeDelete Rate Topic: -----

#1 User is offline   StephenL 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 23-November 16

Posted 13 December 2016 - 01:26 AM

Hello para master yii, saya sedang membuat system invoice dengan relasi 3 table (produk, invoice, invoice_detail)
(1.) produk (id_produk, Nama_produk, harga)
(2.) invoice (id_invoice, tgl_invoice, total)
(3.) invoice_detail (id_detail, id_invoice, id_produk, qty, total)

semua relasi dibagian inputnya sudah oke semua, masalahnya pada bagian delete jika saya mendelete isi table invoice form PK(id_invoice) tetapi invoice_detailnya tidak mau terhapus.

setelah saya cari-cari dengan cara afterdelete dan beforedelete bagaimana saya dapat menerapkan after dan before pada script saya ya?.
berikut potongan scripnya

invoiceController:

function actionDelete($id)
{
	$data= new Invoice;
	$model= $data->findByPK($id)->delete();
}


invoicedetail (model):

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(
       				'ProdukRel' => array(self::BELONGS_TO,'Produk','id_produk'),
        			'InvoiceRel' => array(self::BELONGS_TO,'Invoice','id_invoice'),
        	);
}

berikut saya lampirkan contohnya : saya mendelete id_invoice PK (4).

Attached File(s)


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