title: Changing sql query to yii2 format
body: <p>Am using dataProvider and i would like to convert a query in sql so that it follows the dataProvider way of representing data</p>
  
  <p>This is the raw sql</p>
  
  <pre><code>            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
  </code></pre>
  
  <p>These are the relations i have in the tblpritems</p>
  
  <pre><code>     public function getPR()
  {
      return $this-&gt;hasOne(Tblpr::className(), ['PRID' =&gt; 'PRID']);
  }
  
  /**
   * @return \yii\db\ActiveQuery
   */
  public function getPrSolicitation()
  {
      return $this-&gt;hasOne(Tblprsolicitations::className(), ['pr_solicitation_id' =&gt; 'pr_solicitation_id']);
  }
  </code></pre>
  
  <p>Currently am using </p>
  
  <pre><code>$dataProvider = new SqlDataProvider([
          'sql' =&gt; $sql,
          'pagination' =&gt; [
              'pageSize' =&gt; 10,
          ],
      ]);
  </code></pre>
  
  <p>But the problems is that i cant access $dataProvider->getAttributes() in sql dataProvider</p>
  
  <p>I would like the sql code above to be in this format</p>
  
  <pre><code>$query = Tblprsuppliers::find()
          -&gt;Joinwith('prSolicitation', 'prSolicitation.pr_solicitation_id = tblprsuppliers.pr_solicitation_id')
          -&gt;Joinwith('supplier', 'supplier.supplier_id = tblprsuppliers.supplier_id')
          -&gt;JoinWith('currency', 'currency.CurrencyID = tblprsuppliers.currency_id ');
  </code></pre>
  
  <p>How can i achieve this</p>
  
  <p>This is the database schema</p>
  
  <p><a href="https://i.stack.imgur.com/b87Om.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b87Om.png" alt="enter image description here"></a></p>