git.ithinksw.org
/
extjs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git]
/
examples
/
writer
/
remote
/
lib
/
model.php
diff --git
a/examples/writer/remote/lib/model.php
b/examples/writer/remote/lib/model.php
index
cf0ef2f
..
38f52af
100644
(file)
--- a/
examples/writer/remote/lib/model.php
+++ b/
examples/writer/remote/lib/model.php
@@
-6,7
+6,7
@@
class Model {
public $id, $attributes;
static function create($params) {
class Model {
public $id, $attributes;
static function create($params) {
- $obj = new self(
$params
);
+ $obj = new self(
get_object_vars($params)
);
$obj->save();
return $obj;
}
$obj->save();
return $obj;
}
@@
-24,13
+24,15
@@
class Model {
static function update($id, $params) {
global $dbh;
$rec = self::find($id);
static function update($id, $params) {
global $dbh;
$rec = self::find($id);
+
if ($rec == null) {
return $rec;
}
$rs = $dbh->rs();
if ($rec == null) {
return $rec;
}
$rs = $dbh->rs();
+
foreach ($rs as $idx => $row) {
if ($row['id'] == $id) {
foreach ($rs as $idx => $row) {
if ($row['id'] == $id) {
- $rec->attributes = array_merge($rec->attributes,
$params
);
+ $rec->attributes = array_merge($rec->attributes,
get_object_vars($params)
);
$dbh->update($idx, $rec->attributes);
break;
}
$dbh->update($idx, $rec->attributes);
break;
}
@@
-55,7
+57,7
@@
class Model {
}
public function __construct($params) {
}
public function __construct($params) {
- $this->id =
$params["id"] ||
null;
+ $this->id =
isset($params['id']) ? $params['id'] :
null;
$this->attributes = $params;
}
public function save() {
$this->attributes = $params;
}
public function save() {