Yii Framework Forum: Tiap Transaksi Ngurangin Stok Yg Ada Di Tabel Master - Yii Framework Forum

Jump to content

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

Tiap Transaksi Ngurangin Stok Yg Ada Di Tabel Master Rate Topic: -----

#1 User is offline   angga pratama 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 30-January 13

Posted 04 February 2013 - 12:04 AM

kasusnya gini kan ada tabel master n tabel transaksi,, pas create transaksi stock yang di table master pengen berkurang,, udah nggoogling ada sih tapi ga paham soalnya b.inggris,, masih phobia kalo b. inggris,, hhe :D
mohon solusinya ya para masta-masta Yii
0

#2 User is offline   Dayak Ngoding 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 14-November 11

Posted 07 February 2013 - 04:48 AM

View Postangga pratama, on 04 February 2013 - 12:04 AM, said:

kasusnya gini kan ada tabel master n tabel transaksi,, pas create transaksi stock yang di table master pengen berkurang,, udah nggoogling ada sih tapi ga paham soalnya b.inggris,, masih phobia kalo b. inggris,, hhe :D
mohon solusinya ya para masta-masta Yii


Misal ada model master di Master(id, jumlah) dan transaksi di Transaksi (id, id_master_barang, jumlah_dibeli) ...

Lalu ada yang membeli maka kurang lebih ...

$trans = new Transaksi;
$trans->setIsNewRecord(true);
$trans->id_master_barang = '111';
$trans->jumlah_dibeli = 4;
$trans->save();

$master = Master::model()->find('id=?', array($trans->id_master_barang));
$master->jumlah -= $trans->jumlah_dibeli;
$master->save();

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