Add update_builder()

master
Vitaliy Filippov 2018-11-04 16:29:41 +03:00
parent bcd5521cea
commit 192ca77d94
1 changed files with 13 additions and 5 deletions

View File

@ -3,7 +3,7 @@
/**
* PDO/PostgreSQL wrapper with (mostly) DatabaseMySQL interface :)
* Select builder is inspired by MediaWiki's one.
* Version: 2018-10-21
* Version: 2018-11-04
* (c) Vitaliy Filippov, 2015-2018
*/
@ -789,6 +789,17 @@ class DatabasePdoPgsql implements Database
* @param array $where Conditions for update query, see $this->where_builder().
*/
function update($table, $set, $where = NULL, $options = NULL)
{
$sql = $this->update_builder($table, $set, $where, $options);
if (!$sql)
return false;
$r = $this->query($sql);
if ($r)
return $r->rowCount();
return false;
}
function update_builder($table, $set, $where = NULL, $options = NULL)
{
if (!$set)
return false;
@ -808,10 +819,7 @@ class DatabasePdoPgsql implements Database
$where = array_merge($where, $more);
$where = $this->where_builder($where) ?: '1=1';
$sql .= ' WHERE ' . $where;
$r = $this->query($sql);
if ($r)
return $r->rowCount();
return false;
return $sql;
}
/**