Added update method
This commit is contained in:
parent
62e755d1f1
commit
2b63ba42ca
1 changed files with 27 additions and 0 deletions
27
src/WPDO.php
27
src/WPDO.php
|
|
@ -185,6 +185,33 @@ class WPDO {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function update($fields, $values_update, $where_sql, $values) {
|
||||||
|
|
||||||
|
$fields=$this->check_fields($fields);
|
||||||
|
|
||||||
|
if(count($fields)!=count($values_update)) {
|
||||||
|
|
||||||
|
throw new Exception('No valid values for insert in '.$this->table->name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//$final_fields=implode('`, `', $fields);
|
||||||
|
$final_fields=[];
|
||||||
|
|
||||||
|
foreach($fields as $field) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$query='update '.$this->table->name.' SET ';
|
||||||
|
//echo $query;
|
||||||
|
$this->sth=$this->conn->prepare($query);
|
||||||
|
|
||||||
|
return $this->sth->execute($values);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function check_fields($fields) {
|
public function check_fields($fields) {
|
||||||
|
|
||||||
if($fields[0]!='*') {
|
if($fields[0]!='*') {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue