From a7cdb3e411cc947b64a843be3bd945582c917d17 Mon Sep 17 00:00:00 2001 From: till Date: Tue, 27 Nov 2012 18:45:57 +0100 Subject: [PATCH] WIP: Hack to support composite/compound keys. --- library/Controller.php | 14 +++++++++++--- views/scripts/crud/list.phtml | 8 ++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/library/Controller.php b/library/Controller.php index af74170..4a0da08 100644 --- a/library/Controller.php +++ b/library/Controller.php @@ -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); diff --git a/views/scripts/crud/list.phtml b/views/scripts/crud/list.phtml index 4c5d3d9..1b94a5a 100644 --- a/views/scripts/crud/list.phtml +++ b/views/scripts/crud/list.phtml @@ -18,11 +18,11 @@ paginator as $row): ?> - + $val): ?> primary[0]) { - $_primary = $val; + if (in_array($col, $this->primary)) { + $_primary[$col] = $val; } ?> cols)): ?> @@ -30,7 +30,7 @@ - Detail + Detail