I have an array that receives precisely 18 values. Each "key" of this array is a time and each value of this is an SQL query. I pass this array to a json file to bring the data objects I need. The problem is that this array prints several times and I only need it to print once with all the selects.
.... action....
$selectDezenove = Doctrine::getTable('Atendimentos')->createQuery('a')
->where('time(a.data_hora) =', $this->horarios );
$this->horarios = array();
$this->horarios["08:20"] = $selectDezenove;
$this->horarios["08:40"] = $selectDezenove;
.....
.... json.php ...
foreach($horarios as $horario => $atendimento)
{
foreach($records as $atendimento)
{
if( date("H:i", strtotime($atendimento->getDataHora())) === $horario )
{
$list[] =
'{'."\n".
' "id":'. $atendimento->getId().','."\n".
' "cell":'."\n".
' ['."\n".
' "'.$atendimento->getId().'",'."\n".
' "'.$horario.'",'."\n".
++dados+++
}
else
{
$list[] =
'{'."\n".
' "id":'.$atendimento->getId().','."\n".
' "cell":'."\n".
' ['."\n".
' "",'."\n".
' "'.$horario.'",'."\n".
++dados++
}
if($atendimento == NULL )
{
$list[] =
'{'."\n".
' "id":'.$atendimento->getId().','."\n".
' "cell":'."\n".
' ['."\n".
' "",'."\n".
' "'.$horario.'",'."\n".
+++dados+++
}
}
}
}
....... fim json .....
The problem is that my result is being printed many times, type for every% of_content that returns 1 result, is printing the list with all arrays , if I have 2 results it will print 1 array of 18 positions 2 times, if you have 3 results, 1 array with 18 positions 3 times ... and so on.
What can be wrong about this? I'm working with the symfony 1.4 framework, with ORM Doctrine 1.4