File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace kbtests \Models ;
4
4
5
- use karmabunny \pdb \Pdb ;
5
+ use karmabunny \pdb \Exceptions \ RowMissingException ;
6
6
7
7
/**
8
8
* Base models from Sprout.
@@ -49,7 +49,11 @@ protected function _internalSave(array &$data)
49
49
$ table = static ::getTableName ();
50
50
51
51
if ($ this ->id > 0 ) {
52
- $ pdb ->update ($ table , $ data , [ 'id ' => $ this ->id ]);
52
+ $ count = $ pdb ->update ($ table , $ data , [ 'id ' => $ this ->id ]);
53
+
54
+ if (!$ count ) {
55
+ throw new RowMissingException ("Failed to update record for ' {$ table }' " );
56
+ }
53
57
}
54
58
else {
55
59
$ data ['id ' ] = $ pdb ->insert ($ table , $ data );
@@ -58,11 +62,15 @@ protected function _internalSave(array &$data)
58
62
if (property_exists ($ this , 'uid ' )) {
59
63
$ data ['uid ' ] = $ pdb ->generateUid ($ table , $ data ['id ' ]);
60
64
61
- $ pdb ->update (
65
+ $ count = $ pdb ->update (
62
66
$ table ,
63
67
[ 'uid ' => $ data ['uid ' ] ],
64
68
[ 'id ' => $ data ['id ' ] ]
65
69
);
70
+
71
+ if (!$ count ) {
72
+ throw new RowMissingException ("Failed to update record for ' {$ table }' " );
73
+ }
66
74
}
67
75
}
68
76
}
You can’t perform that action at this time.
0 commit comments