CakePHP Fatal Error: Allowed memory size of 134217728 bytes exhausted
EDIT: Stellt sich heraus, meine DB-Schlüssel wurden nicht richtig konfiguriert, was bedeutet, dass der controller in eine Endlosschleife, wenn es versucht, Sie zum abrufen der Liste der Verkäufer.
Vielen Dank für die Hilfe!
CakePHP Neuling hier.
Bin ich mit cakePHP Gerüst, um die Inhalte anzuzeigen, die von einem einzigen Modell (Account Manager) und die zugehörigen Modelle (Verkäufer und Sitzungen).
Es gibt aktuell 2 Account Manager (Sie haben 3 Attribute), rund 220 Verkäufer (mit rund 20 Attribute) und 2 treffen (mit 4 Parametern) in die Datenbank.
Vor einer Woche, das alles geklappt hat, aber plötzlich, wenn ich versuche, die Ansicht der details zu einem single-Account-Manager, ich bekomme diese Fehlermeldung:
Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 44613632 bytes)
Datei: ...\app\View\Layouts\default.ctp
Line: 70
Ist die Zeile:
<?php echo $this->fetch('content'); ?>
Und es ist Teil der Standard-layout, das ist, mal wieder, zur Verfügung gestellt von den Gerüsten.
Ich habe versucht, die Erhöhung der Speicher-limit, aber dann wird der code nur mal nach einer Weile.
Auch glaube ich nicht scheinen, um den Zugriff auf die Datenbank, die viel von fetch, die viel von info trigger so etwas wie dieses.
Ich bin neu bei cakePHP so meine debugging-Erfahrung ist sehr begrenzt.
Hier ist der Ausschnitt aus dem controller-view-Methode:
public function view($id = null) {
if (!$this->AccountManager->exists($id)) {
throw new NotFoundException(__('Invalid account manager'));
}
$options = array('conditions' => array('AccountManager.' . $this->AccountManager->primaryKey => $id));
$this->set('accountManager', $this->AccountManager->find('first', $options));
}
Hier ist das Modell für Account Manager:
<?php
App::uses('AppModel', 'Model');
/**
* AccountManager Model
*
* @property Primary $Primary
* @property Seller $Seller
* @property Meeting $Meeting
*/
class AccountManager extends AppModel {
/**
* Display field
*
* @var string
*/
public $displayField = 'first_name';
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* hasMany associations
*
* @var array
*/
public $hasMany = array(
'Primary' => array(
'className' => 'Primary',
'foreignKey' => 'account_manager_id',
'dependent' => false
),
'Seller' => array(
'className' => 'Seller',
'foreignKey' => 'account_manager_id',
'dependent' => false
)
);
/**
* hasAndBelongsToMany associations
*
* @var array
*/
public $hasAndBelongsToMany = array(
'Meeting' => array(
'className' => 'Meeting',
'joinTable' => 'account_managers_meetings',
'foreignKey' => 'account_manager_id',
'associationForeignKey' => 'meeting_id',
'unique' => 'keepExisting'
)
);
}
Ist hier der Ansicht:
<div class="accountManagers view">
<h2><?php echo __('Account Manager'); ?></h2>
<dl>
<dt><?php echo __('First Name'); ?></dt>
<dd>
<?php echo h($accountManager['AccountManager']['first_name']); ?>
</dd>
<dt><?php echo __('Last Name'); ?></dt>
<dd>
<?php echo h($accountManager['AccountManager']['last_name']); ?>
</dd>
</dl>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul>
<li><?php echo $this->Html->link(__('Edit Account Manager'), array('action' => 'edit', $accountManager['AccountManager']['id'])); ?> </li>
<li><?php echo $this->Form->postLink(__('Delete Account Manager'), array('action' => 'delete', $accountManager['AccountManager']['id']), null, __('Are you sure you want to delete # %s?', $accountManager['AccountManager']['id'])); ?> </li>
</ul>
</div>
<div class="related">
<h3><?php echo __('Related Sellers'); ?></h3>
<?php if (!empty($accountManager['Seller'])): ?>
<table cellpadding = "0" cellspacing = "0">
<tr>
<th><?php echo __('Id'); ?></th>
<th><?php echo __('Username'); ?></th>
<th><?php echo __('Account Type'); ?></th>
<th><?php echo __('First Name'); ?></th>
<th><?php echo __('Last Name'); ?></th>
<th><?php echo __('Primary Id'); ?></th>
<th><?php echo __('Third Party Id'); ?></th>
<th><?php echo __('Email'); ?></th>
<th><?php echo __('Work Phone'); ?></th>
<th><?php echo __('Cell Phone'); ?></th>
<th><?php echo __('Address'); ?></th>
<th><?php echo __('City'); ?></th>
<th><?php echo __('Zip'); ?></th>
<th><?php echo __('Country'); ?></th>
<th><?php echo __('Store Url'); ?></th>
<th><?php echo __('Main Site'); ?></th>
<th><?php echo __('Main Vertical'); ?></th>
<th><?php echo __('Main Category'); ?></th>
<th><?php echo __('Birthday'); ?></th>
<th><?php echo __('Notes'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
<?php
$i = 0;
foreach ($accountManager['Seller'] as $seller): ?>
<tr>
<td><?php echo $this->Html->link($seller['id'], array('controller' => 'sellers', 'action' => 'view', $seller['id'])); ?></td>
<td><?php echo $this->Html->link($seller['username'], array('controller' => 'sellers', 'action' => 'view', $seller['id'])); ?></td>
<td><?php echo $seller['account_type']; ?></td>
<td><?php echo $seller['first_name']; ?></td>
<td><?php echo $seller['last_name']; ?></td>
<td><?php echo $seller['primary_id']; ?></td>
<td><?php echo $seller['third_party_id']; ?></td>
<td><?php echo $seller['email']; ?></td>
<td><?php echo $seller['work_phone']; ?></td>
<td><?php echo $seller['cell_phone']; ?></td>
<td><?php echo $seller['address']; ?></td>
<td><?php echo $seller['city']; ?></td>
<td><?php echo $seller['zip']; ?></td>
<td><?php echo $seller['country']; ?></td>
<td><?php echo $seller['store_url']; ?></td>
<td><?php echo $seller['main_site']; ?></td>
<td><?php echo $seller['main_vertical']; ?></td>
<td><?php echo $seller['main_category']; ?></td>
<td><?php echo $seller['birthday']; ?></td>
<td><?php echo $seller['notes']; ?></td>
<td class="actions">
<?php echo $this->Html->link(__('Edit'), array('controller' => 'sellers', 'action' => 'edit', $seller['id'])); ?>
<?php echo $this->Form->postLink(__('Delete'), array('controller' => 'sellers', 'action' => 'delete', $seller['id']), null, __('Are you sure you want to delete # %s?', $seller['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<div class="actions">
<ul>
<li><?php echo $this->Html->link(__('New Seller'), array('controller' => 'sellers', 'action' => 'add')); ?> </li>
</ul>
</div>
</div>
<div class="related">
<h3><?php echo __('Related Meetings'); ?></h3>
<?php if (!empty($accountManager['Meeting'])): ?>
<table cellpadding = "0" cellspacing = "0">
<tr>
<th><?php echo __('Interface'); ?></th>
<th><?php echo __('Date'); ?></th>
<th><?php echo __('Notes'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
<?php
$i = 0;
foreach ($accountManager['Meeting'] as $meeting): ?>
<tr>
<td><?php echo $this->Html->link($meeting['interface'], array('controller' => 'meetings', 'action' => 'view', $meeting['id'])); ?></td>
<td><?php echo $meeting['date']; ?></td>
<td><?php echo $meeting['notes']; ?></td>
<td class="actions">
<?php echo $this->Html->link(__('Edit'), array('controller' => 'meetings', 'action' => 'edit', $meeting['id'])); ?>
<?php echo $this->Form->postLink(__('Delete'), array('controller' => 'meetings', 'action' => 'delete', $meeting['id']), null, __('Are you sure you want to delete # %s?', $meeting['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<div class="actions">
<ul>
<li><?php echo $this->Html->link(__('New Meeting'), array('controller' => 'meetings', 'action' => 'add')); ?> </li>
</ul>
</div>
</div>
Setzen
die;
am Ende der Ansicht. Wenn es keine Fehler, es ist eine Schleife in Ihrem layout. Wenn es das gleiche problem, verschieben Sie die Würfel, um zu identifizieren, die code-Zeile verantwortlich.Ich habe versucht, das hinzufügen, das die(); aber dann bekomme ich nur eine weiße Seite ohne Fehlercode aus vor.
Versuchen Sie
var_dump($accountManager); die();
oben in der Ansicht für die Fehlersuche. Vielleicht ist Ihr Datenbank-definition enthält einige weitere Beziehungen, die sind alle abgeholt rekursiv. E. g. wenn der Verkäufer die Bestellung, die Positionen, die Links zu Produkten, Kategorien und so weiter, könnten Sie Holen die ganze Datenbank.
InformationsquelleAutor wonderv | 2013-06-22
Du musst angemeldet sein, um einen Kommentar abzugeben.
Sie nicht über genügend Arbeitsspeicher für die php-Skript, fügen Sie diese:
HINWEIS: Dies sagen zu php interprer zu verwenden, alle Speicher, das Skript zu benötigen, so werfen Sie einen Blick auf Ihre Umgebung.
InformationsquelleAutor onalbi