Skip to content

Commit 1853907

Browse files
committed
Merge pull request #369 from avbdr/master
fixes
2 parents 5b3c0ce + 555fcb7 commit 1853907

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

MysqliDb.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,18 +660,19 @@ public function has($tableName)
660660
*
661661
* @param string $tableName The name of the database table to work with.
662662
* @param array $tableData Array of data to update the desired row.
663+
* @param int $numRows Limit on the number of rows that can be updated.
663664
*
664665
* @return bool
665666
*/
666-
public function update($tableName, $tableData)
667+
public function update($tableName, $tableData, $numRows = null)
667668
{
668669
if ($this->isSubQuery) {
669670
return;
670671
}
671672

672673
$this->_query = "UPDATE " . self::$prefix . $tableName;
673674

674-
$stmt = $this->_buildQuery(null, $tableData);
675+
$stmt = $this->_buildQuery($numRows, $tableData);
675676
$status = $stmt->execute();
676677
$this->reset();
677678
$this->_stmtError = $stmt->error;

readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ else
152152
echo 'update failed: ' . $db->getLastError();
153153
```
154154

155+
`update()` also support limit parameter:
156+
```php
157+
$db->update ('users', $data, 10);
158+
// Gives: UPDATE users SET ... LIMIT 10
159+
```
160+
155161
### Select Query
156162
After any select/get function calls amount or returned rows is stored in $count variable
157163
```php

0 commit comments

Comments
 (0)