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) {
141141 case 'hasone ' :
142142 $ obj = new $ modelName ;
143143 $ 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 ];
145146 break ;
146147 case 'hasmany ' :
147148 $ key = $ this ->relations [$ name ][2 ];
148149 $ obj = new $ modelName ;
149150 $ 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 ];
151153 break ;
152154 default :
153155 break ;
@@ -268,8 +270,12 @@ public function update ($data = null) {
268270 * @return mixed insert id or false in case of failure
269271 */
270272 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+ }
273279 return $ this ->update ($ data );
274280 }
275281
You can’t perform that action at this time.
0 commit comments