Good day. I'm creating a dashboard with cakephp 1.3 that displays all
job line items. I am having trouble displaying the rep name instead
of the id. I don't know if I need a custom query instead or if I can
still use the find function. Here is the table structure:
*job_line_items
|---id
| *vendors
|---vendor_id-----> |---------id
| *processes
|---process_id---> |---------id
| *jobs
|---job_id----------> |---------id *reps
|---------rep_id------> |-- id
|--name
Here are my dashboard controller and view file.
//dashboards_controller.php
class DashboardsController extends AppController {
var $name = 'Dashboards';
var $uses = array();
function index() {
$job_line_items =
ClassRegistry::init('JobLineItem')->find('all');
$this->set(compact('job_line_items'));
}
}
//index.ctp
<table cellpadding="0" cellspacing="0">
<?php
$i = 0;
foreach ($job_line_items as $jobLineItem):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<tr<?php echo $class;?>>
<td><?php echo $jobLineItem['Job']['rep_id']; ?> </
td> // I would like NAME to be displayed here instead
<td><?php echo $jobLineItem['Job']['job_number']; ?></td>
<td><?php echo $jobLineItem['Vendor']['name']; ?></td>
<td><?php echo $jobLineItem['Process']['name']; ?></
td>
</tr>
<?php endforeach; ?>
</table>
All I can retrieve is the rep_id. Do I need to have a custom query or
join? Can cakephp natively handle the results I want with find? Can
anyone comment on the efficiency of the dashboard controller? Is
there something I can change to make things more efficient? Thank you.
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