yii\db\Query::innerJoin PHP Méthode

innerJoin() public méthode

Appends an INNER JOIN part to the query.
public innerJoin ( string | array $table, string | array $on = '', array $params = [] )
$table string | array the table to be joined. Use a string to represent the name of the table to be joined. The table name can contain a schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u'). The method will automatically quote the table name unless it contains some parenthesis (which means the table is given as a sub-query or DB expression). Use an array to represent joining with a sub-query. The array must contain only one element. The value must be a [[Query]] object representing the sub-query while the corresponding key represents the alias for the sub-query.
$on string | array the join condition that should appear in the ON part. Please refer to [[join()]] on how to specify this parameter.
$params array the parameters (name => value) to be bound to the query.
    public function innerJoin($table, $on = '', $params = [])
    {
        $this->join[] = ['INNER JOIN', $table, $on];
        return $this->addParams($params);
    }

Usage Example

 /**
  * Lists all Product models.
  * @return mixed
  */
 public function actionIndex()
 {
     $products = new Query();
     $products->select('*')->from('product');
     $products->innerJoin('store_product', ['store_product.product_id' => 'product.id']);
     $dataProvider = new ActiveDataProvider(['query' => $products]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
All Usage Examples Of yii\db\Query::innerJoin