public static function deleteOrder($id) { PDOConnexion::setParameters('phonedeals', 'root', 'root'); $db = PDOConnexion::getInstance(); $sql = 'DELETE FROM orders WHERE id = :id'; $sth = $db->prepare($sql); $sth->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Order'); $sth->execute(array(':id' => $id)); }
public static function getBrandList() { PDOConnexion::setParameters('phonedeals', 'root', 'root'); $db = PDOConnexion::getInstance(); $sql = 'SELECT * FROM brand'; $sth = $db->prepare($sql); $sth->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Brand'); $sth->execute(); return $sth->fetchAll(); }
<?php if (isset($_GET['id']) && !empty($_GET['id'])) { $id = htmlentities($_GET['id']); $promotion = Promotion::getPromotionById($id); if (isset($_POST['edit'])) { if (preg_match("#^([0-9]{1,2}|100)\$#", $_POST['percent'])) { PDOConnexion::setParameters('phonedeals', 'root', 'root'); $db = PDOConnexion::getInstance(); $sql = "\n\t\t\t\tUPDATE promotion\n\t\t\t\tSET percent = :percent\n\t\t\t\tWHERE id = :id\n\t\t\t"; $sth = $db->prepare($sql); $sth->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Promotion'); $sth->execute(array(':id' => $id, ':percent' => $_POST['percent'])); if ($sth) { App::success('La promotion a bien été modifiée'); } } else { App::error("Les champs ne sont pas valides"); } } if ($member) { ?> <div class="col-md-8"> <div class="page-header"> <h1>Éditer une promotion</h1> </div> <form action="index.php?page=admin/promotion-edit&id=<?php echo $id; ?> " method="POST">
public static function setParameters($_dbname, $_user, $_pwd) { self::$dbname = $_dbname; self::$user = $_user; self::$pwd = $_pwd; }