in my tasks controller, i am simply trying to find all tasks with status of
"Completed" and then of course echo them out in a foreach.
But for some reason, only one record is printing that meets the criteria,
but there are many more that should be.
Here is my code:
tasks_controller.php
function index() {
$this->Task->recursive = 0;
$this->set('tasks', $this->paginate());
// code to pull the Completed status items
$allStatuses= $this->Status->Task->find('all');
$statuses = $this->Task->Status->find('all',
array('conditions'=>array('Status.name'=>'Completed')));
$this->set(compact('task','statuses'));
}
************************************************************************
tasks - index.ctp
<table>
<?php foreach ($statuses as $status ): ?>
<tr>
<td><?php echo $status['Status']['name']; ?></td>
<td><?php echo $task['Priority']['name']; ?></td>
<td><?php echo $task['Task']['description']; ?></td>
<td><?php echo $task['Task']['duration']; ?></td>
<td><?php echo $task['Company']['name']; ?></td>
<td><?php echo $task['Employee']['name']; ?></td>
</tr>
<?php endforeach; ?>
</table>
Any ideas as to why this is happening?
--
View this message in context:
http://www.nabble.com/controller-condition-find-%3A%3A-only-retrieving-one-record--%3A%3A-foreach-%3A%3A-should-be-printing-many-tp23690573p23690573.html
Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---