Commit 3db07e36 authored by Alex Ne's avatar Alex Ne

Для БД, функции

	public function increment($table, $column, $where = [], $value = 1)
	public function decrement($table, $column, $where = [], $value = 1)
parent 6381e8fe
...@@ -221,6 +221,24 @@ class PDO { ...@@ -221,6 +221,24 @@ class PDO {
return $statement->execute(); return $statement->execute();
} }
public function increment($table, $column, $where = [], $value = 1) {
$SQL = "UPDATE `{$table}` SET `{$column}` = `{$column}` + {$value} ";
$whete_obj = new PDOWhereConstructor($where);
$SQL .= $whete_obj->get_sql();
$statement = $this->prepare($SQL);
$whete_obj->bind($statement);
return $statement->execute();
}
public function decrement($table, $column, $where = [], $value = 1) {
$SQL = "UPDATE `{$table}` SET `{$column}` = `{$column}` - {$value} ";
$whete_obj = new PDOWhereConstructor($where);
$SQL .= $whete_obj->get_sql();
$statement = $this->prepare($SQL);
$whete_obj->bind($statement);
return $statement->execute();
}
/** /**
* @param $table * @param $table
* @param $where * @param $where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment