antonbar
(Antonbar)
April 12, 2015, 3:45pm
1
Hi all,
First of all thanks for checking this post out.
I use Yii 1.1.12 and I have an issue with one call to findAll. The code looks like this:
$sql = ‘provider_id=’ . $this->provider->provider_id;
$items = Item::model()->findAll($sql, array());
the findAll crashes and the response goes out empty.if I put echo’s around find all the one before it returns and the one after it does not.
The table of items is quite large, so it might be related.
I think so especially because it works if I change the $sql like this:
$sql = array(‘condition’ => ‘provider_id=’ . $this->provider->provider_id, ‘limit’ => 1000, ‘order’ => ‘id desc’);
Many thanks in advance
Anton.
le_top
(Ext Yiiframework Com)
April 13, 2015, 9:45pm
2
In the case where it does not work, you set $sql to a string, and in the case where it works, you set it to an array. Might that not be related?
for first scenario it should be like this :
$sql = ‘provider_id=’ . $this->provider->provider_id;
$items = Item::model()->findAll(['condition = '.$sql);
check docs CActiveRecord.findAll
1 Like
georaldc
(Georaldc)
April 14, 2015, 6:38pm
4
You’re probably running out of memory. Active record can be a bit demanding because it returns much more than just your selected table columns. You could try limiting the columns being selected to reduce the footprint, adn/or resort to lazy loading if you are eager-pulling in too many relations.
Is there a reason why you need to load all data at once and not just paginate it?
antonbar
(Antonbar)
April 15, 2015, 2:02pm
5
Thanks for replying.
I tried using an array, doesn’t help unfortunately.
antonbar
(Antonbar)
April 15, 2015, 2:06pm
6
Thanks georaldc, looks like it’s indeed the case. I’ll do pagination.