File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -141,13 +141,15 @@ public function __get ($name) {
141
141
case 'hasone ' :
142
142
$ obj = new $ modelName ;
143
143
$ obj ->returnType = $ this ->returnType ;
144
- return $ obj ->byId ($ this ->data [$ name ]);
144
+ $ this ->data [$ name ] = $ obj ->byId ($ this ->data [$ name ]);
145
+ return $ this ->data [$ name ];
145
146
break ;
146
147
case 'hasmany ' :
147
148
$ key = $ this ->relations [$ name ][2 ];
148
149
$ obj = new $ modelName ;
149
150
$ obj ->returnType = $ this ->returnType ;
150
- return $ obj ->where ($ key , $ this ->data [$ this ->primaryKey ])->get ();
151
+ $ this ->data [$ name ] = $ obj ->where ($ key , $ this ->data [$ this ->primaryKey ])->get ();
152
+ return $ this ->data [$ name ];
151
153
break ;
152
154
default :
153
155
break ;
@@ -268,8 +270,12 @@ public function update ($data = null) {
268
270
* @return mixed insert id or false in case of failure
269
271
*/
270
272
public function save ($ data = null ) {
271
- if ($ this ->isNew )
272
- return $ this ->insert ();
273
+ if ($ this ->isNew ) {
274
+ $ id = $ this ->insert ();
275
+ if (isset ($ this ->primaryKey ))
276
+ $ this ->data [$ this ->primaryKey ] = $ id ;
277
+ return $ id ;
278
+ }
273
279
return $ this ->update ($ data );
274
280
}
275
281
You can’t perform that action at this time.
0 commit comments