Commit 761fa36260f8698b6b372222c675727b9be6d047
1 parent
a07c0bce
test
Showing
1 changed file
with
16 additions
and
6 deletions
Show diff stats
app/library/App/Controllers/UserController.php
@@ -66,14 +66,24 @@ class UserController extends CrudResourceController | @@ -66,14 +66,24 @@ class UserController extends CrudResourceController | ||
66 | 66 | ||
67 | $data = $this->transformPostData($data); | 67 | $data = $this->transformPostData($data); |
68 | 68 | ||
69 | - $item = $this->createModelInstance(); | ||
70 | 69 | ||
71 | - $newItem = $this->createItem($item, $data); | 70 | + //$item = $this->createModelInstance(); |
71 | + | ||
72 | + //$newItem = $this->createItem($item, $data); | ||
73 | + | ||
74 | + $newItem = new User(); | ||
75 | + $map = $newItem->columnMap(); | ||
76 | + foreach ($data as $key => $value) { | ||
77 | + if (in_array($key, $map)) | ||
78 | + $newItem->$key = $value; | ||
79 | + } | ||
72 | 80 | ||
73 | if (!$newItem) { | 81 | if (!$newItem) { |
74 | return $this->onCreateFailed($item, $data); | 82 | return $this->onCreateFailed($item, $data); |
75 | } | 83 | } |
76 | 84 | ||
85 | + $newItem->save(); | ||
86 | + | ||
77 | $primaryKey = $this->getModelPrimaryKey(); | 87 | $primaryKey = $this->getModelPrimaryKey(); |
78 | $responseData = $this->getFindData($newItem->$primaryKey); | 88 | $responseData = $this->getFindData($newItem->$primaryKey); |
79 | 89 | ||
@@ -105,9 +115,9 @@ class UserController extends CrudResourceController | @@ -105,9 +115,9 @@ class UserController extends CrudResourceController | ||
105 | /** | 115 | /** |
106 | * fix phql for PG | 116 | * fix phql for PG |
107 | */ | 117 | */ |
108 | -// protected function getModelPrimaryKey() | ||
109 | -// { | ||
110 | -// return 'id'; | ||
111 | -// } | 118 | + protected function getModelPrimaryKey() |
119 | + { | ||
120 | + return 'id'; | ||
121 | + } | ||
112 | 122 | ||
113 | } | 123 | } |