I've done some testing with this issue, and this is what I found out:

<?php

$array  =       array(
        "Interno",
        "id"
);

$step = count($array) - 1;

foreach (range(0, $step) as $number) {
    echo '<p>'.$number.'</p>';
}

$datetime1 = new DateTime('2010-08-2');
$datetime2 = new DateTime('2009-07-30');

$interval = date_diff($datetime1,$datetime2);
?>

the warning only comes up when the date_diff function is used. If the
date_diff command line is commented out, it range call does not throw
a warning. So I guess this is more a php bug(?) than a Cake problem.

On Aug 21, 2:11 pm, Marcos  Mendonça <marc...@gmail.com> wrote:
> I'm sure.
>
> With $internacoes[0]['data_entrada'] I'm just picking the first
> element of the $internacoes array. That works fine.
>
> On Aug 20, 1:43 pm, cricket <zijn.digi...@gmail.com> wrote:
>
> > 2010/8/20 Marcos  Mendonça <marc...@gmail.com>:
>
> > > 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?
>
> > Are you sure that line 13 is not this one?
>
> > $data_in = new DateTime($internacoes[0]['data_entrada']);
>
> > That [0] looks odd to me. Try this:
>
> > $this->set('interno', $this->Interno->read(null, $id));
>
> > die(debug($this->Interno->data));

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to