Skip to content
This repository has been archived by the owner on Dec 24, 2021. It is now read-only.

Commit

Permalink
WIP: Hack to support composite/compound keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
till committed Nov 27, 2012
1 parent d91b252 commit a7cdb3e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 11 additions & 3 deletions library/Controller.php
Expand Up @@ -206,13 +206,21 @@ public function indexAction()
*/
public function readAction()
{
$pkey = $this->primaryKey[0];
//$pkey = $this->primaryKey[0];

if (null === ($id = $this->_getParam($pkey))) {
if (null === ($id = $this->_getParam('primary-key'))) {
return $this->_helper->redirector('list');
}

$record = $this->obj->find($id)->toArray();
$primaryKey = unserialize($id);

$record = call_user_func_array(
array($this->obj, 'find'),
array_values($primaryKey)
)->toArray();

//$this->obj->find($id)->toArray();

$this->view->assign('record', $record[0]);
$this->view->assign('pkValue', $id);
return $this->render('crud/detail', null, true);
Expand Down
8 changes: 4 additions & 4 deletions views/scripts/crud/list.phtml
Expand Up @@ -18,19 +18,19 @@
<tbody>
<?php foreach ($this->paginator as $row): ?>
<tr>
<?php $_primary = null; ?>
<?php $_primary = array(); ?>
<?php foreach ($row as $col => $val): ?>
<?php
if ($col == $this->primary[0]) {
$_primary = $val;
if (in_array($col, $this->primary)) {
$_primary[$col] = $val;
}
?>
<?php if (in_array($col, $this->cols)): ?>
<td class="data-<?php echo $col; ?>"><?php echo $val; ?></td>
<?php endif; ?>
<?php endforeach; ?>
<td>
<a href="<?php echo $this->BetterUrl(array('action' => 'read', $this->primary[0] => $_primary)); ?>">Detail</a>
<a href="<?php echo $this->BetterUrl(array('action' => 'read', 'primary-key' => serialize($_primary))); ?>">Detail</a>
</td>
</tr>
<?php endforeach; ?>
Expand Down

0 comments on commit a7cdb3e

Please sign in to comment.