正在使用數據提供程序,我想查詢轉換成SQL以便它跟隨代表數據更改SQL查詢來yii2格式
這是原始的SQL
SELECT
tblpritems.PRlineID
, tblpritems.Tracking_Code
, tblpritems.Description
, tblpritems.Quantity
, tblpritems.Unit_Price
, tblpritems.Extended_price
, tblpritems.PRID
, tblpritems.pr_solicitation_id
, tblpritems.date_item_received
, tblpritems.Quantity_received
, tblpritems.Remarks_on_receipt
, tblpritems.Received_by
FROM
prts.tblpritems
INNER JOIN prts.tblpr
ON (tblpritems.PRID = tblpr.PRID)
INNER JOIN prts.tblprsolicitations
ON (tblprsolicitations.PRID = tblpr.PRID) AND (tblpritems.pr_solicitation_id = tblprsolicitations.pr_solicitation_id)
INNER JOIN prts.tblprsuppliers
ON (tblprsuppliers.pr_solicitation_id = tblprsolicitations.pr_solicitation_id)
INNER JOIN prts.tblpo
ON (tblpo.pr_supplier_id = tblprsuppliers.pr_supplier_id)
where tblpr.PRID=".$val." and tblpo.PO_Status_ID=7 and item_received_status=0
這些的dataProvider方式關係我在tblpritems
public function getPR()
{
return $this->hasOne(Tblpr::className(), ['PRID' => 'PRID']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getPrSolicitation()
{
return $this->hasOne(Tblprsolicitations::className(), ['pr_solicitation_id' => 'pr_solicitation_id']);
}
目前正在使用
$dataProvider = new SqlDataProvider([
'sql' => $sql,
'pagination' => [
'pageSize' => 10,
],
]);
但問題是,我不能訪問$ dataProvider->的getAttributes()的SQL數據提供程序
我想上面的SQL代碼將在這個格式
$query = Tblprsuppliers::find()
->Joinwith('prSolicitation', 'prSolicitation.pr_solicitation_id = tblprsuppliers.pr_solicitation_id')
->Joinwith('supplier', 'supplier.supplier_id = tblprsuppliers.supplier_id')
->JoinWith('currency', 'currency.CurrencyID = tblprsuppliers.currency_id ');
我怎樣才能做到這一點
這是數據庫架構
()? –