Hi All,
Could someone help me on this?
I have three tables,
transaction
-----------
id int PK
transactionNo varchar(50) not null
date date not null
memo text null
status tinyint(2) not null
transaction_detail
------------------
id int PK
transactionFk int not null 'FK to transaction(id)
itemFk int not null 'FK to item(id)
quantity decimal(15,2) not null
unitPrice decimal(15,2) not null
item
----
id int PK
code varchar(15) not null
name varchar (40) not null
unit varchar(10) not null
description text null
status tinyint(2) not null
The question is that how could I make a relation to details order by item.name
* @return array relational rules.
*/
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(
'details' => array(self::HAS_MANY, 'TransactionDetail', 'transactionFk'),
'totalTransaction' => array(self::STAT, 'TransactionDetail', 'transactionFk', 'select' => 'SUM(quantity * unitPrice)'),
'totalItems' => array(self::STAT, 'TransactionDetail', 'transactionFk', 'select' => 'SUM(quantity)'),
);
}
Thank you in advance.