- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
// table for cart must have unique index for both columns for correct effect of this function
function save() {
if ($this->errno_ || !$this->db_link_)
return;
// optimized loop
$n = count($this->products_) - 1;
$s_query = "REPLACE INTO `". Config::DB_CART_TABLE_NAME ."` VALUES ";
for($i = 0; $i < $n; ++$i) {
$s_query .= "('". $this->phpsessid_ ."',". $this->products_[$i]->getId() .",". $this->counts_[$i] .",'". $this->sizes_[$i] ."')";
}
if ($n + 1)
$s_query .= "('". $this->phpsessid_ ."',". $this->products_[$n]->getId() .",". $this->counts_[$n] .",'". $this->sizes_[$n] ."')";
print($s_query);
$res = mysqli_query($this->db_link_, $s_query);
if (!$res)
$this->errno_ = IModel::E_DB_QUERY;
}
// Запрос сформирован некорректно, нету запятых между кортежами значений:/
// REPLACE INTO `cart` VALUES ('cbn1c7ljjd3gglb2lmpa96grnq3prq2iefb2elvcb4fhr9r0qls1',700,4,'')('cbn1c7ljjd3gglb2lmpa96grnq3prq2iefb2elvcb4fhr9r0qls1',701,2,'')
Опять мой говнокод.
И это как-то србатывало О_о
someone 10.04.2019 10:54 # 0
BOKCEJIbHblu_nemyx 10.04.2019 11:13 # 0
guest6 15.02.2023 15:23 # 0
JloJle4Ka 15.02.2023 15:25 # 0