/** * Get all users. * * @return array(User) all users. */ public static function getAll() { $sQuery = 'select * from user'; $aUsers = array(); foreach (DBOperation::getAll($sQuery) as $aProduct) { $aUsers[] = self::convertToObject($aProduct); } return $aUsers; }
public static function getAllOrder() { $query = "SELECT * FROM commandes"; $result = DBOperation::getAll($query); $orders = []; foreach ($result as $order) { $orders[] = new Order($order['prix'], $order['id_user'], $order['id'], $order['date']); } return $orders; }
public static function getOrders() { $sQuery = " select * from orders "; $sQuery .= " ORDER BY date DESC "; $aAllOrders = []; foreach (DBOperation::getAll($sQuery) as $aOrder) { $aAllOrders[] = self::convertToObject($aOrder); } return $aAllOrders; }
public static function getAllComments(Product $oProduct = null) { $sQuery = 'select * from comment '; if ($oProduct !== null) { $sQuery .= ' WHERE product_id = ' . $oProduct->getId(); $sQuery .= ' AND validated = 0'; } else { $sQuery .= ' WHERE validated = 0'; } $aAllComments = array(); foreach (DBOperation::getAll($sQuery) as $aComment) { $aAllComments[] = self::convertToObject($aComment); } return $aAllComments; }
public static function getProduct($id) { $query = "SELECT *, produits.id as id_produit FROM produits\n\t\t\t\t\tLEFT JOIN images on produits.id=images.id_produit\n\t\t\t\t\tWHERE produits.id=" . $id . " AND deleted=0"; if ($products = DBOperation::getAll($query)) { $result = null; foreach ($products as $product) { if (!isset($result)) { $result = new Product($product["id_produit"], $product["nom"], $product["description"], $product["prix"]); } $result->setImage($product["link"]); } return $result; } return false; }
public static function getAllFromOrder($id) { $sQuery = " select * from product LEFT JOIN order_product ON product.id = order_product.product_id"; $sQuery .= " WHERE order_id = " . $id; $aAllOrders = []; foreach (DBOperation::getAll($sQuery) as $aOrder) { $aAllOrders[] = self::convertToObject($aOrder); } return $aAllOrders; }
public static function getNumberProducts() { $sQuery = " SELECT category.id, category.name, category.description, COUNT( product_id ) AS numberproducts "; $sQuery .= " FROM category INNER JOIN product_category ON category.id = product_category.category_id"; $sQuery .= " GROUP BY category.id, category.name, category.description"; $aCategories = array(); foreach (DBOperation::getAll($sQuery) as $aCategory) { $aCategories[] = $aCategory; } return $aCategories; }