Пример #1
0
 public function getGroup($id = NULL)
 {
     if ($id) {
         $stmt = $this->pdo->PDOInstance->prepare("SELECT * FROM group_product WHERE id= :id");
         $stmt->bindParam(':id', $id);
     } else {
         $stmt = $this->pdo->PDOInstance->prepare("SELECT * FROM group_product");
     }
     try {
         $stmt->execute();
     } catch (Exception $e) {
         echo "Problem at " . $e->getLine() . " from model Extraction :" . $e->getMessage();
     }
     $stmt = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $result = array();
     foreach ($stmt as $group) {
         $group_ = new group_products();
         $group_->setId($group["id"]);
         $group_->setName($group["name"]);
         $group_->setType($group["type"]);
         array_push($result, $group_);
     }
     return $result;
 }
Пример #2
0
<?php

require_once '../model/group_products.php';
$group_products = new group_products();
if ($_GET["name"] != "") {
    $group_products->setName($_GET["name"]);
    $group_products->setType($_GET["type"]);
    $group_products->addToDatabase();
}
header('location:' . $_GET["next"]);
Пример #3
0
<?php

require_once '../model/group_products.php';
$groupProduct = new group_products($_GET['id']);
foreach ($_GET as $key => $value) {
    if ($key != "next" && $value != "") {
        echo $key . ' -> ' . $value . '<br/>';
        $nkey = "set" . ucfirst($key);
        echo $nkey . '<br/>';
        try {
            $groupProduct->{$nkey}($value);
        } catch (Exception $e) {
            echo 'shit';
        }
    }
}
$groupProduct->setToDatabase();
header('location:' . $_GET['next']);
<?php

require_once '../model/group_products.php';
try {
    $id = $_GET["id"];
} catch (Exception $e) {
    header('location:viewGroupProducts.php');
    exit;
}
$group_products = new group_products($id);
$group_products->eraseOfDatabase();
header('location:viewGroupProducts.php');
exit;