I'm facing a problem with a site I'm building using the Yii framework.
In the site I have a form for the Photos model. The Photos model is related to the Stores model like so:
Stores Model
public function relations()
{
return array(
'photos' => array(self::HAS_MANY, 'Photo', 'storeId'),
...
Photos Model
public function relations()
{
return array(
'store' => array(self::BELONGS_TO, 'Store', 'storeId'),
);
}
In the Photos form, I am trying to get a dropdown with the list of all the stores like so:
<div class="row">
<?php echo $form->labelEx($model,'storeId'); ?>
<?php
//The below line is causing the problem
echo $form->dropDownList($model,'storeId',
CHtml::listData(Store::model()->findAll(), 'id', 'name'));
?>
<?php echo $form->error($model,'storeId'); ?>
</div>
What's happening is that the page rendering breaks down at the dropdownList line. If I remove the line, the form displays properly. I have a feeling this might be because the store model's relationship with the photo model, but can't quite figure out why, or how to fix this.
Can somebody shed some light on what could be happening? Thanks!
Edit:
Figured it out partly!
I temporarily fixed the issue by adding the following code:
$criteria = new CDbCriteria();
$criteria->limit = 10;
$stores = Store::model()->findAll($criteria);
It seems the problem is that the Store table has too many records (more than 35000), which is causing some problems. Maybe this is a memory issue?