Skip to content

Commit

Permalink
Merge pull request #369 from avbdr/master
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
avbdr committed Nov 25, 2015
2 parents 5b3c0ce + 555fcb7 commit 1853907
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions MysqliDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,18 +660,19 @@ public function has($tableName)
*
* @param string $tableName The name of the database table to work with.
* @param array $tableData Array of data to update the desired row.
* @param int $numRows Limit on the number of rows that can be updated.
*
* @return bool
*/
public function update($tableName, $tableData)
public function update($tableName, $tableData, $numRows = null)
{
if ($this->isSubQuery) {
return;
}

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

$stmt = $this->_buildQuery(null, $tableData);
$stmt = $this->_buildQuery($numRows, $tableData);
$status = $stmt->execute();
$this->reset();
$this->_stmtError = $stmt->error;
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ else
echo 'update failed: ' . $db->getLastError();
```

`update()` also support limit parameter:
```php
$db->update ('users', $data, 10);
// Gives: UPDATE users SET ... LIMIT 10
```

### Select Query
After any select/get function calls amount or returned rows is stored in $count variable
```php
Expand Down

0 comments on commit 1853907

Please sign in to comment.