File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -316,15 +316,16 @@ public function update($tableName, $tableData)
316316
317317 $ this ->_query = "UPDATE " . self ::$ _prefix . $ tableName ." SET " ;
318318
319- $ stmt = $ this ->_buildQuery (null , $ tableData );
319+ $ stmt = $ this ->_buildQuery (null , $ tableData );
320320 if ($ stmt ->execute () == false ) {
321321 $ this ->reset ();
322322 $ this ->_stmtError = $ stmt ->error ;
323- return - 1 ;
323+ return false ;
324324 }
325325 $ this ->reset ();
326+ $ this ->count = $ stmt ->affected_rows ;
326327
327- return ( $ stmt -> affected_rows > 0 ) ;
328+ return true ;
328329 }
329330
330331 /**
Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ $data = Array(
6868$id = $db->insert ('users', $data);
6969if ($id)
7070 echo 'user was created. Id=' . $id;
71+ else
72+ echo 'insert failed: ' . $db->getLastError();
73+
7174```
7275
7376### Update Query
@@ -81,14 +84,11 @@ $data = Array (
8184 // active = !active;
8285);
8386$db->where ('id', 1);
84- $cols = $db->update ('users', $data);
85- if ($cols == -1)
86- echo 'update failed: ' . $db->getLastError();
87+ if ($db->update ('users', $data))
88+ echo $db->count . ' records were updated';
8789else
88- echo $cols . ' records were updated' ;
90+ echo 'update failed: ' . $db->getLastError() ;
8991```
90- Note that update query will return 0 in case update query will fail AND also in case
91- where no records were modified.
9292
9393### Select Query
9494After any select/get function calls amount or returned rows
You can’t perform that action at this time.
0 commit comments