I'm getting this error on a given view.
Warning (2): range() [function.range]: step exceeds the specified
range [CORE\cake\libs\set.php, line 235]
range - [internal], line ??
Set::numeric() - CORE\cake\libs\set.php, line 235
DboSource::fields() - CORE\cake\libs\model\datasources\dbo_source.php,
line 2019
DboSource::generateAssociationQuery() - CORE\cake\libs\model
\datasources\dbo_source.php, line 1217
DboSource::read() - CORE\cake\libs\model\datasources\dbo_source.php,
line 811
Model::find() - CORE\cake\libs\model\model.php, line 2093
Model::read() - CORE\cake\libs\model\model.php, line 1128
InternosController::view() - APP\controllers\internos_controller.php,
line 13
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
[main] - APP\webroot\index.php, line 83
Line 13 of my controller is:
$this->set('interno', $this->Interno->read(null, $id));
This is the view method:
function view($id = null) {
if (!empty($id)) {
$this->set('interno', $this->Interno->read(null, $id)); //
line 13
$internacoes = $this->Interno->data['Internacoes'];
$data_in = new DateTime($internacoes[0]['data_entrada']);
if (empty($internacoes[0]['data_saida'])) {
$data_out = new DateTime;
} else {
$data_out = new DateTime($internacoes[0]
['data_saida']);
}
$duracao = $data_in->diff($data_out);
$this->set('duracao', $duracao);
} else {
$this->redirect(array('action' => 'index'));
}
}
This is my model:
class Interno extends AppModel {
var $name = 'Interno';
var $helpers = array('Time');
var $validate = array(
'nome' => array('rule' => 'notEmpty'));
var $hasMany = array(
'Internacoes' => array(
'className' => 'Internacao',
'order' => 'Internacoes.created DESC'),
'Visitas' => array(
'className' => 'Visita',
'order' => 'Visitas.data DESC'),
'Enderecos' => array('className' => 'Endereco'));
var $hasAndBelongsToMany = array(
'Contato' => array (
'className' => 'Contato',
'joinTable' => 'contatos_internos',
'foreignKey' => 'interno_id',
'associationForeignKey' => 'contato_id'));
}
My suspicions are on the DateTime and date_diff usage, because when I
take that part of the code off, it works smoothly with no warnings.
Any ideas of what could be going on here?
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en