Dear Community,
I can not make a positive value through subtraction into a negative one.
I have already checked the if query itself and the invoice in the execution, I hope you can help me, greetings AzeS.
private function update_item($ID,$QUA) {
$sql = $this->db->prepare("SELECT stack,time FROM items WHERE ID=:e");
$sql->execute(array(':e' => $ID));
$res = $sql->fetch(PDO::FETCH_ASSOC);
echo $res['stack'] - $QUA;
if (count($res)) {
if ($res['stack'] == 0 || $res['stack'] > 0 || $res['stack'] - $QUA > 0 || $res['stack'] - $QUA == 0 ) {
echo "HERE1";
$sql = $this->db->prepare("UPDATE items SET stack=:f AND dod=:g AND position=:h WHERE ID=:e");
$pa = $res['time'] + 4;
$pb = $res['time'] + 8;
$dod = "This item is not there Maybe in. " . $pa . "-" . $pb . " OT's it's there.";
$sql->execute(array(':f' => $res['stack'] - $QUA, ':g' => $dod, ':h' => 0, ':e' => $ID));
return 1;
} else {
echo "HERE1";
$sql = $this->db->prepare("UPDATE items SET stack=:f WHERE ID=:e");
$sql->execute(array(':f' => $res['stack'] - $QUA, ':e' => $ID));
return 1;
}
}
return 0;
}