Yii Framework Forum: [ASK]Relational DB - Yii Framework Forum

Jump to content

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

[ASK]Relational DB Rate Topic: -----

#1 User is offline   kfahmi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 19-March 12

Posted 03 May 2012 - 10:25 PM

aku mau nanya ini ada relasi tbl_reim dan tbl_emp


tbl_reim (Reim Model)

1.id_reim
2.id_emp
3.Status
blablabla

tbl_emp (Emp Model)
1.id_emp
2.name

class Reim extends CActiveRecord
{
public function relations()
	{
		 
		return array(
			'idEmp' => array(self::BELONGS_TO, 'Emp', 'id_emp'),
			  
	 
		);
	}
}



class Emp extends CActiveRecord
{
public function relations()
	{
		 
		return array(
			 
			 
			'reims' => array(self::HAS_MANY, 'Reim', 'id_emp'),
			'numReims' => array(self::STAT, 'Reim', 'id_emp'),
			'numReimsPend' => ///////ini yang saya tanya, JUMLAH Reim tiap id_emp yang statusnya=0////
		);
	}
}


untuk relation numReims kan itu hasilnya jumlah data milik tiap id_emp yang ada di model reim.

nah saya tanya bisa gak untuk numReimsPend itu hasilnya jumlah data milik tiap id_emp yang ada di model reim yang statusnya = 0. gmn yahhhhh... :(


terima kasih
0

#2 User is offline   tito cah amikom 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 06-February 12

Posted 04 May 2012 - 04:02 AM

coba ini gan pake STAT n condition di relasi nya


'numReimsPend' => array(self::STAT, 'Reim', 'id_emp', 'condition' => 'statusnya=0'),

semoga berhasil gan
0

#3 User is offline   kfahmi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 19-March 12

Posted 08 May 2012 - 11:27 PM

View Posttito cah amikom, on 04 May 2012 - 04:02 AM, said:

coba ini gan pake STAT n condition di relasi nya


'numReimsPend' => array(self::HAS_MANY, 'Reim', 'id_emp', 'condition' => 'statusnya=0'),

semoga berhasil gan



'numReimsPend' => array(self::HAS_MANY, 'Reim', 'id_emp', 'condition' => 'statusnya=0'),

ane tinggal Count di gridviewnya gan :) thanks yaaa
0

#4 User is offline   tito cah amikom 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 06-February 12

Posted 22 June 2012 - 04:13 AM

yok i gan sama sama selamat belajar yii
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