Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. function create(){
  2.  
  3.     // очистка
  4.     $this->consumption_id=htmlspecialchars(strip_tags($this->consumption_id));
  5.     $this->product_id=htmlspecialchars(strip_tags($this->product_id));
  6.     $this->vendor_cod=htmlspecialchars(strip_tags($this->vendor_cod));
  7.     $this->recipient_id=htmlspecialchars(strip_tags($this->recipient_id));
  8.     $this->price=htmlspecialchars(strip_tags($this->price));
  9.     $this->quantity=htmlspecialchars(strip_tags($this->quantity));
  10.     $this->size=htmlspecialchars(strip_tags($this->size));
  11.     $this->provider_id=htmlspecialchars(strip_tags($this->provider_id));
  12.     $this->color=htmlspecialchars(strip_tags($this->color));
  13.     $this->name=htmlspecialchars(strip_tags($this->name));
  14.  
  15.     // запрос для вставки (создания) записей
  16.     $query = "
  17.     INSERT INTO `{$this->table_name}`
  18.     (
  19.     `product_id`,
  20.     `vendor_cod`,
  21.     `recipient_id`,
  22.     `price`,
  23.     `quantity`,
  24.     `size`,
  25.     `provider_id`,
  26.     `color`,
  27.     `name`
  28.     )
  29.     VALUE (
  30.     '{$this->product_id}',
  31.     '{$this->vendor_cod}',
  32.     '{$this->recipient_id}',
  33.     '{$this->price}',
  34.     '{$this->quantity}',
  35.     '{$this->size}',
  36.     '{$this->provider_id}',
  37.     '{$this->color}',
  38.     '{$this->name}'
  39.     )
  40.     ";
  41.  
  42.     // подготовка запроса
  43.     $stmt = $this->conn->prepare($query);
  44.  
  45.     // выполняем запрос
  46.     if ($stmt->execute()) {
  47.         return true;
  48.     }
  49.  
  50.     return false;
  51. }
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement