cactivedataprovider

Many-to-many relation in yii2 activedataprovider

三世轮回 提交于 2021-01-28 05:01:07
问题 I have many-to-many relation with three tables: Category , Product , ProductCategory . Relation in Category : public function getProductCategories() { return $this->hasMany(ProductCategory::className(), ['category_id' => 'id']); } Relation in Product : public function getProductCategories() { return $this->hasMany(ProductCategory::ClassName(), ['product_id' => 'id']); } And in ProductCategory public function getProduct() { return $this->hasOne(Product::className(), ['id' => 'product_id']); }

Foreach through a large table using Yii ActiveRecord - “out of memory” errors

纵饮孤独 提交于 2020-01-05 04:00:51
问题 I have a website on Yii Framework and I want to search a table for matching words. I keep getting "out of memory" (it is a large table). I try this code but it keeps loading the page $dataProvider = new CActiveDataProvider('Data'); $iterator = new CDataProviderIterator($dataProvider); foreach($iterator as $data) { echo $data->name."\n"; } So I try this code but it keeps limiting the result to 10: $dataProvider = new CActiveDataProvider('Data'); $iterator = new CDataProviderIterator(