Example #1
0
function updateUtilisateur($idUser, $idDroit)
{
    $db = new ConnexionDb();
    $query = "UPDATE user SET idTypeUser=:idTypeDroit WHERE idUser=:idUser";
    $res_update = $db->getConnexion()->prepare($query);
    $res_update->bindParam(':idTypeDroit', $idDroit, PDO::PARAM_INT);
    $res_update->bindParam(':idUser', $idUser, PDO::PARAM_INT);
    $res_update->execute();
}
Example #2
0
function loadDomaine()
{
    $db = new ConnexionDb();
    $requete_domaine = "SELECT idDomaine,libelleDomaine FROM domaine ORDER BY idDomaine;";
    $res_domaine = $db->getConnexion()->prepare($requete_domaine);
    $res_domaine->execute();
    $domaines = $res_domaine->fetchAll(PDO::FETCH_OBJ);
    return $domaines;
}
Example #3
0
function ajout_image($imagePath, $idProduit)
{
    $db = new ConnexionDb();
    $query = "INSERT INTO imageproduit(cheminImage, idProduit) VALUES(:cheminImage, :idProduit);";
    $res_image = $db->getConnexion()->prepare($query);
    $res_image->bindParam(":cheminImage", $imagePath, PDO::PARAM_STR);
    $res_image->bindParam(":idProduit", $idProduit, PDO::PARAM_INT);
    $res_image->execute();
}
Example #4
0
function load_select($table)
{
    $db = new ConnexionDb();
    $query = "SELECT * FROM {$table}";
    $res_table = $db->getConnexion()->prepare($query);
    $res_table->execute();
    $table_select = $res_table->fetchAll(PDO::FETCH_OBJ);
    return $table_select;
}
Example #5
0
function loadCommandes()
{
    $db = new ConnexionDb();
    $query = "SELECT idCommande, prix, dateCommande,user.idUser, nom, prenom\n              FROM commande\n              INNER JOIN user\n              ON commande.idUser = user.idUser";
    $res_commande = $db->getConnexion()->prepare($query);
    $res_commande->execute();
    $commandes = $res_commande->fetchAll(PDO::FETCH_OBJ);
    return $commandes;
}
Example #6
0
function loadTheme($idDomaine)
{
    $db = new ConnexionDb();
    $requete_theme = "SELECT idTheme, libelleTheme FROM theme WHERE idDomaine = :domaine";
    $res_theme = $db->getConnexion()->prepare($requete_theme);
    $res_theme->bindParam(":domaine", $idDomaine, PDO::PARAM_INT);
    $res_theme->execute();
    $themes = $res_theme->fetchAll(PDO::FETCH_OBJ);
    return $themes;
}
Example #7
0
function ajout_produit($produit)
{
    $db = new ConnexionDb();
    $query = "INSERT INTO produit(nomProduit, prixProduit, description, stock, idTheme) VALUES(:nomProduit, :prixProduit, :description, :stock, :idTheme);";
    $res_produit = $db->getConnexion()->prepare($query);
    $res_produit->bindParam(":nomProduit", $produit["nom"], PDO::PARAM_STR);
    $res_produit->bindParam(":prixProduit", $produit["prix"], PDO::PARAM_STR);
    $res_produit->bindParam(":description", $produit["description"], PDO::PARAM_STR);
    $res_produit->bindParam(":stock", $produit["stock"], PDO::PARAM_INT);
    $res_produit->bindParam(":idTheme", $produit["theme"], PDO::PARAM_INT);
    $res_produit->execute();
    return $db->getConnexion()->lastInsertId();
}
Example #8
0
function ajouter_utilisateur($utilisateur)
{
    $db = new ConnexionDb();
    $stmt = $db->getConnexion()->prepare("INSERT INTO user(nom,prenom,login,mdp, idTypeUser) VALUES (:nom, :prenom, :login, :mdp, 2);");
    //Encodage du password
    if (isset($utilisateur['mdp'])) {
        $utilisateur['mdp'] = password_hash($utilisateur['mdp'], PASSWORD_DEFAULT);
    }
    $stmt->bindParam(':nom', $utilisateur['nom'], PDO::PARAM_STR);
    $stmt->bindParam(':prenom', $utilisateur['prenom'], PDO::PARAM_STR);
    $stmt->bindParam(':login', $utilisateur['login'], PDO::PARAM_STR);
    $stmt->bindParam(':mdp', $utilisateur['mdp'], PDO::PARAM_STR);
    $stmt->execute();
}
function connexion_utilisateur($utilisateur)
{
    $db = new ConnexionDb();
    $stmt = $db->getConnexion()->prepare("SELECT login, mdp, nom, prenom, niveau FROM user\n                                          INNER JOIN typeuser\n                                          ON user.idTypeUser = typeuser.idTypeUser\n                                          INNER JOIN droit\n                                          ON typeuser.idDroit = droit.idDroit\n                                          WHERE login=:login;");
    $stmt->bindParam(':login', $utilisateur['login'], PDO::PARAM_STR);
    $stmt->execute();
    $registered_utilisateur = $stmt->fetch(PDO::FETCH_OBJ);
    if ($registered_utilisateur == false) {
        return false;
    }
    if (password_verify($utilisateur['mdp'], $registered_utilisateur->mdp)) {
        return $registered_utilisateur;
    } else {
        return false;
    }
}
Example #10
0
<?php

/**
 * Created by PhpStorm.
 * User: user
 * Date: 08/02/2016
 * Time: 15:05
 */
require_once "ConnexionDb.class.php";
$db = new ConnexionDb();
$requete_produits = "SELECT produit.idProduit,\n                                    produit.nomProduit,\n                                    produit.prixProduit,\n                                    theme.libelleTheme,\n                                    domaine.libelleDomaine\n                             FROM produit\n                             INNER JOIN theme ON produit.idTheme = theme.idTheme\n                             INNER JOIN domaine ON theme.idDomaine = domaine.idDomaine";
$requete_image = "SELECT imageproduit.cheminImage\n                              FROM imageproduit\n                              WHERE idProduit = :id;";
if ($critere_get != null) {
    $requete_produits .= " WHERE " . key($critere_get) . ".libelle" . ucwords(key($critere_get)) . " = :critere;";
} else {
    if (isset($critere_post) && $critere_post != null) {
        $premier = true;
        if (isset($rech_produit)) {
            $requete_produits .= " WHERE nomProduit LIKE :produit ";
            $premier = false;
        }
        if (isset($rech_prix_min)) {
            if ($premier == true) {
                $requete_produits .= " WHERE prixProduit >= :prix_min ";
                $premier = false;
            } else {
                $requete_produits .= " AND prixProduit >= :prix_min ";
            }
        }
        if (isset($rech_prix_max)) {
            if ($premier == true) {
Example #11
0
<?php

/**
 * Created by PhpStorm.
 * User: user
 * Date: 23/02/2016
 * Time: 16:11
 */
require_once $_SERVER["DOCUMENT_ROOT"] . "/theWood/back/Models/ConnexionDb.class.php";
$db = new ConnexionDb();
$requete_domaine = "SELECT idDomaine,libelleDomaine FROM domaine ORDER BY idDomaine;";
$res_domaine = $db->getConnexion()->prepare($requete_domaine);
$res_domaine->execute();
$domaines = $res_domaine->fetchAll(PDO::FETCH_OBJ);
$requete_theme = "SELECT libelleTheme FROM theme WHERE idDomaine = :domaine";
$res_theme = $db->getConnexion()->prepare($requete_theme);
foreach ($domaines as $d) {
    $res_theme->bindParam(":domaine", $d->idDomaine, PDO::PARAM_INT);
    $res_theme->execute();
    $d->themes = $res_theme->fetchAll(PDO::FETCH_OBJ);
}
Example #12
0
<?php

/**
 * Created by PhpStorm.
 * User: user
 * Date: 15/03/2016
 * Time: 16:53
 */
require_once "ConnexionDb.class.php";
$db = new ConnexionDb();
$requete = "SELECT nomProduit,stock FROM produit WHERE idProduit = :id;";
$res = $db->getConnexion()->prepare($requete);
foreach ($panier as $p) {
    $res->bindParam(":id", $p["id"], PDO::PARAM_INT);
    $res->execute();
    $stock = $res->fetch(PDO::FETCH_OBJ);
    if ($stock->stock < intval($p["nb"])) {
        $erreur = 1;
        $produit_erreur = $stock->nomProduit;
        $stock_erreur = $stock->stock;
        break;
    }
    $res->closeCursor();
}
if (!isset($erreur)) {
    $user = $_SESSION["utilisateur"]->login;
    $requete_prix = "SELECT prixProduit FROM produit WHERE idProduit = :id;";
    $res = $db->getConnexion()->prepare($requete_prix);
    $prixtotal = 0;
    foreach ($panier as $p) {
        $res->bindParam(":id", $p["id"], PDO::PARAM_INT);
Example #13
0
<?php

/**
 * Created by PhpStorm.
 * User: user
 * Date: 14/03/2016
 * Time: 16:10
 */
require_once "ConnexionDb.class.php";
$db = new ConnexionDb();
$requete = "SELECT idProduit,nomProduit,prixProduit FROM produit WHERE FIND_IN_SET(idProduit, :produits);";
$res = $db->getConnexion()->prepare($requete);
$produits = implode(",", $array_prod);
$res->bindParam(":produits", $produits, PDO::PARAM_INT);
$res->execute();
$infos_prod = $res->fetchAll(PDO::FETCH_OBJ);
Example #14
0
<?php

/**
 * Created by PhpStorm.
 * User: user
 * Date: 08/02/2016
 * Time: 15:07
 */
require_once "ConnexionDb.class.php";
$id = $_GET["id"];
$db = new ConnexionDb();
$requete_produit = "SELECT produit.idProduit,\n                               produit.nomProduit,\n                               produit.description,\n                               produit.prixProduit,\n                               produit.stock,\n                               theme.libelleTheme,\n                               domaine.libelleDomaine\n                        FROM produit\n                        INNER JOIN theme ON produit.idTheme = theme.idTheme\n                        INNER JOIN domaine ON theme.idDomaine = domaine.idDomaine\n                        WHERE produit.idProduit = :id;";
$requete_image = "SELECT imageproduit.cheminImage\n                      FROM imageproduit\n                      WHERE idProduit = :id;";
$requete_tag = "SELECT libelleTag FROM tag\n                    INNER JOIN produit_tag ON tag.idTag = produit_tag.idTag\n                    WHERE idProduit = :id;";
$res_produit = $db->getConnexion()->prepare($requete_produit);
$res_produit->bindParam(":id", $id, PDO::PARAM_INT);
$res_produit->execute();
$produit = $res_produit->fetch(PDO::FETCH_OBJ);
$res_image = $db->getConnexion()->prepare($requete_image);
$res_image->bindParam(":id", $produit->idProduit, PDO::PARAM_INT);
$res_image->execute();
$produit->images = $res_image->fetchAll(PDO::FETCH_OBJ);
$res_tag = $db->getConnexion()->prepare($requete_tag);
$res_tag->bindParam(":id", $produit->idProduit, PDO::PARAM_INT);
$res_tag->execute();
$produit->tags = $res_tag->fetchAll(PDO::FETCH_OBJ);
Example #15
0
<?php

/**
 * Created by PhpStorm.
 * User: user
 * Date: 08/03/2016
 * Time: 17:43
 */
require_once "ConnexionDb.class.php";
$db = new ConnexionDb();
$requete_stock = "SELECT stock FROM produit WHERE idProduit = :id;";
$res_stock = $db->getConnexion()->prepare($requete_stock);
$res_stock->bindParam(":id", $id_produit, PDO::PARAM_INT);
$res_stock->execute();
$stock = $res_stock->fetch(PDO::FETCH_OBJ);
$stock_produit = intval($stock->stock);