· 6 years ago · Sep 17, 2019, 08:14 AM
1 private function insert($domain, $product_id) {
2 $domain = mysqli_real_escape_string($this->_db, clearStr($domain));
3 $product_id = clearInt($product_id);
4 //$value = mysqli_real_escape_string($this->_db, clearStr($value));
5
6 $sql = "CREATE TABLE IF NOT EXISTS `$domain` (
7 `id` int(11) NOT NULL,
8 `product_id` int(255),
9 `title` text,
10 `description` text,
11 `link` text,
12 `price` text,
13 `sale_price` text,
14 `google_product_category` text,
15 `availability` text,
16 `brand` text,
17 `image_link` text,
18 PRIMARY KEY (`id`)
19 ) ENGINE=InnoDB DEFAULT CHARSET=utf8";
20
21// if(!mysqli_query($this->_db, $sql)) {
22// $err = mysqli_errno($this->_db);
23// }
24
25 $sqlInsert = "INSERT INTO `$domain` (`link`, `product_id`) VALUES (?, ?)";
26
27 if ($stmt = $this->prepare($sqlInsert)) {
28 $stmt->bind_param("si", $domain, $product_id);
29
30 if ($stmt->execute()) {
31 $stmt->store_result();
32
33 if ($stmt->num_rows > 0) {
34 return true;
35 } else {
36 file_put_contents('../file.txt', "Error insert to bd". "\n", FILE_APPEND);
37 return false;
38 }
39 }
40 }
41 }