Skip to content

Instantly share code, notes, and snippets.

@shabaz-ejaz
Last active October 16, 2018 13:11
Show Gist options
  • Save shabaz-ejaz/c327759fbf2b610b52adadbd7cba4a45 to your computer and use it in GitHub Desktop.
Save shabaz-ejaz/c327759fbf2b610b52adadbd7cba4a45 to your computer and use it in GitHub Desktop.
Yii2 Join tables with ActiveRecord
$products = AirtablesProduct:: find()
->with('airtablesProductsTypes.airtablesProductType')
->with('airtablesProductsComponents.airtablesComponent')
->with('airtablesProductsSizes.airtablesProductSize')
->with('airtablesProductsSpecies.airtablesSpecie')
->orderBy('name ASC')
->asArray();
return static::find()->where(['user_referred_by' => $this->id ])->andWhere(['NOT',['user_subscription.id' => null]])->joinWith('subscription')->asArray()->count(); die;
https://stackoverflow.com/questions/28525945/retrieve-data-from-junction-table-in-yii2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment