Commit db21841cbf944f288eb587a3a67c1d28cf8a7d52

Authored by Alex Savenko
1 parent f95462a2

user update

Showing 1 changed file with 64 additions and 22 deletions   Show diff stats
src/lib/models/customers.php
@@ -206,15 +206,15 @@ class customers extends \db @@ -206,15 +206,15 @@ class customers extends \db
206 206
207 public function UpdateData($data,$id) 207 public function UpdateData($data,$id)
208 { 208 {
209 - $pass = empty($data['password']) ? '' : 'passwd = :password,';  
210 - return $this->exec(  
211 - ' 209 + if (!empty($data['password'])) {
  210 + return $this->exec(
  211 + '
212 UPDATE 212 UPDATE
213 public.customers 213 public.customers
214 SET 214 SET
215 name = :name, 215 name = :name,
216 email = :email, 216 email = :email,
217 - '.$pass.' 217 + passwd = :password,
218 birth_date = :birth_date, 218 birth_date = :birth_date,
219 phone = :phone, 219 phone = :phone,
220 city = :city, 220 city = :city,
@@ -229,24 +229,66 @@ class customers extends \db @@ -229,24 +229,66 @@ class customers extends \db
229 WHERE 229 WHERE
230 id = :id 230 id = :id
231 ', 231 ',
232 - [  
233 - 'name' => $data['name'],  
234 - 'email' => $data['email'],  
235 - 'password' => $data['password'],  
236 - 'birth_date' => empty($data['birth_date']) ? null : $data['birth_date'],  
237 - 'phone' => $data['phone'],  
238 - 'city' => $data['city'],  
239 - 'address' => $data['address'],  
240 - 'delivery' => $data['delivery'],  
241 - 'pay' => $data['pay'],  
242 - 'subscribed' => $data['subscribed'],  
243 - 'comments' => $data['comments'],  
244 - 'status' => $data['status'],  
245 - 'users_group_id' => $data['users_group_id'],  
246 - 'special_users_id' => $data['special_users_id'],  
247 - "id" => $id  
248 - ]  
249 - ); 232 + [
  233 + 'name' => $data['name'],
  234 + 'email' => $data['email'],
  235 + 'password' => $data['password'],
  236 + 'birth_date' => empty($data['birth_date']) ? null : $data['birth_date'],
  237 + 'phone' => $data['phone'],
  238 + 'city' => $data['city'],
  239 + 'address' => $data['address'],
  240 + 'delivery' => $data['delivery'],
  241 + 'pay' => $data['pay'],
  242 + 'subscribed' => $data['subscribed'],
  243 + 'comments' => $data['comments'],
  244 + 'status' => $data['status'],
  245 + 'users_group_id' => $data['users_group_id'],
  246 + 'special_users_id' => $data['special_users_id'],
  247 + "id" => $id
  248 + ]
  249 + );
  250 + }
  251 + else {
  252 + return $this->exec(
  253 + '
  254 + UPDATE
  255 + public.customers
  256 + SET
  257 + name = :name,
  258 + email = :email,
  259 + birth_date = :birth_date,
  260 + phone = :phone,
  261 + city = :city,
  262 + address = :address,
  263 + delivery = :delivery,
  264 + pay = :pay,
  265 + subscribed = :subscribed,
  266 + comments = :comments,
  267 + status = :status,
  268 + users_group_id = :users_group_id,
  269 + special_users_id = :special_users_id
  270 + WHERE
  271 + id = :id
  272 + ',
  273 + [
  274 + 'name' => $data['name'],
  275 + 'email' => $data['email'],
  276 + 'birth_date' => empty($data['birth_date']) ? null : $data['birth_date'],
  277 + 'phone' => $data['phone'],
  278 + 'city' => $data['city'],
  279 + 'address' => $data['address'],
  280 + 'delivery' => $data['delivery'],
  281 + 'pay' => $data['pay'],
  282 + 'subscribed' => $data['subscribed'],
  283 + 'comments' => $data['comments'],
  284 + 'status' => $data['status'],
  285 + 'users_group_id' => $data['users_group_id'],
  286 + 'special_users_id' => $data['special_users_id'],
  287 + "id" => $id
  288 + ]
  289 + );
  290 + }
  291 +
250 } 292 }
251 293
252 294