mysql> select distinct pt_product from ylp_transactions where tw_warehouse like "%ELA0020060010%";
+------------+
| pt_product |
+------------+
| 3000001700 |
| 3000002900 |
| 3000003200 |
| 3000006800 |
| 3000008600 |
+------------+
5 rows in set (0.03 sec)
In my database I have this query so when i created a function to the TaxWarehouse model
public function products($warehouse = null)
{
$criteria=new CDbCriteria;
$criteria->distinct = true;
$criteria->select = "pt_product";
if(isset($warehouse)) {
$criteria->compare('tw_warehouse', $warehouse, true);
} else {
$criteria->compare('tw_warehouse', $this->tw_refnumber,true);
}
return Transactions::model()->find($criteria);
}
and when i use this function i get…
public function actionView($id)
{
$warehouseProvider = $this->loadModelByUniq($id);
$productProviders = array();
if(isset($warehouseProvider)) {
var_dump($id);
foreach(TaxWarehouse::model()->products($id) as $tr)
{
var_dump($tr);
}
}
.....
i get this
string(13) "ELA0020060070" string(10) "3000003200" NULL NULL NULL NULL NULL NULL