public function delete($id) { if ($this->checkExistedInBills($id)) { return 1; } $ps = new PreparedStatement("DELETE FROM stocks WHERE id = ?"); $ps->setInt(1, $id); return $this->ds->execute($ps->getSql()) ? 0 : 2; }
function delete($id) { $sql = 'DELETE FROM carts WHERE id = ?'; $ps = new PreparedStatement($sql); $ps->setInt(1, $id); $this->ds->execute($ps->getSql()); $cartItemDAO = new CartItemDAO($this->ds); $cartItemDAO->deleteInCart($id); }
public function delete($id) { $ps = new PreparedStatement("DELETE FROM categories WHERE id = ?"); $ps->setInt(1, $id); if ($this->ds->execute($ps->getSql())) { $productDAO = new ProductDAO($this->ds); $productDAO->updateCat($id, 'NULL'); return TRUE; } return FALSE; }
public function delete($id) { $ps = new PreparedStatement("DELETE FROM cities WHERE id = ?"); $ps->setInt(1, $id); if ($this->ds->execute($ps->getSql())) { $customerDAO = new CustomerDAO($this->ds); $customerDAO->updateCity($id, 'NULL'); return TRUE; } return FALSE; }
public function checkExisted($stock_id) { $ps = new PreparedStatement('SELECT id FROM export_bills WHERE stock_id = ?'); $ps->setInt(1, $stock_id); $rs = $this->ds->execute($ps->getSql()); $ret = FALSE; if (mysql_fetch_array($rs)) { $ret = TRUE; } mysql_free_result($rs); return $ret; }
public function checkLogin($username, $password) { $ps = new PreparedStatement('SELECT group_id FROM members WHERE username = ? AND password = ?'); $ps->setString(1, $username); $ps->setString(2, $password); $rs = $this->ds->execute($ps->getSql()); $ret = 0; if ($row = mysql_fetch_array($rs)) { $ret = (int) $row['group_id']; } mysql_free_result($rs); return $ret; }
private function findMaxOrderInCat($cat_id) { $sql = 'SELECT MAX(order_in_cat) AS max_order FROM products WHERE category_id = ?'; $ps = new PreparedStatement($sql); $ps->setInt(1, $cat_id); $rs = $this->ds->execute($ps->getSql()); $max_order = 0; if ($row = mysql_fetch_array($rs)) { $max_order = (int) $row['max_order']; } mysql_free_result($rs); return $max_order; }
public function deleteInCart($cart_id) { $ps = new PreparedStatement('DELETE FROM cart_items WHERE cart_id = ?'); $ps->setInt(1, $cart_id); return $this->ds->execute($ps->getSql()); }
function delete($id) { $sql = 'DELETE FROM promos WHERE id = ?'; $ps = new PreparedStatement($sql); $ps->setInt(1, $id); return $this->ds->execute($ps->getSql()) ? TRUE : FALSE; }
public function update($col, $content) { $ps = new PreparedStatement('UPDATE global SET ' . $col . ' = ?'); $ps->setString(1, $this->ds->escape($content)); return $this->ds->execute($ps->getSql()); }
public function updateCity($old_city_id, $new_city_id) { $sql = 'UPDATE customers SET city_id = ? WHERE city_id = ?'; $ps = new PreparedStatement($sql); if ($new_city_id == 'NULL') { $ps->setNull(1); } else { $ps->setInt(1, $new_city_id); } $ps->setInt(2, $old_city_id); $this->ds->execute($ps->getSql()); }