[color="#FF0000"]I want to select 1 OR MORE records from the db with the SAME composite key.[/color]
$soldItemList = SoldItem::model()->findByPk(["FK_context_ID"=>5,"FK_GTBtablename_ID"=>1]);
<=This will return me only one record instead of two!
This raw SQL query works perfectly
SELECT * FROM SoldItem WHERE (`FK_context_ID`, `FK_GTBtablename_ID`) = (5, 1)
<=It returns me two rows as it should
Exemple Table: SoldItem
-
id : 3
-
FK_context_ID : [color="#FF0000"]5[/color]
-
FK_GTBtablename_ID: [color="#FF0000"]1[/color]
-
itemName: AK-47
-
id : 4
-
FK_context_ID : [color="#FF0000"]5[/color]
-
FK_GTBtablename_ID: [color="#FF0000"]1[/color]
-
itemName: M-16
Model: SoldItem
...
public function primaryKey()
{
return array('FK_context_ID', 'FK_GTBtablename_ID');
}
...
Model: Transaction
public function relations()
{
return array(
"rel_SoldItem" => array(self::HAS_MANY, "SoldItem", "FK_context_ID",
"condition" =>'rel_SoldItem.FK_GTBtablename_ID = 1')
)
}
As explained by "phtamas" in this post
[color="#0000FF"]I need these multiple records; the fact that these composite keys are not "unique" is irrelevant for me.
Is there a way to turn OFF this collapse of results?[/color]
Thank you for your time