/** * Get a product from its id. * * @param int $iId product id. * * @return Product matched product, null if not found */ public static function get($iId) { $sQuery = 'select * from product where id = ' . $iId . ' limit 1'; $aProductRow = DBOperation::getOne($sQuery); $oProduct = null; if (false !== $aProductRow) { $oProduct = self::convertToObject($aProductRow); } return $oProduct; }
/** * Get a user from its user_email. * * @param string $email user-email. * * @return User matched user, null if not found */ public static function getFromEmail($email) { $sQuery = "select * from user where email = '" . $email . "' limit 1"; $aUserRow = DBOperation::getOne($sQuery); $oUser = null; if (false !== $aUserRow) { $oUser = self::convertToObject($aUserRow); } return $oUser; }
/** * Get a category from its id. * * @param int $iId category id. * * @return Category matched category, null if not found */ public static function get($iId) { $sQuery = 'select * from category where id = ' . $iId . ' limit 1'; $aCategoryRow = DBOperation::getOne($sQuery); $oCategory = null; if (false !== $aCategoryRow) { $oCategory = self::convertToObject($aCategoryRow); } return $oCategory; }
public static function connect(User $user) { $sQuery = "SELECT * FROM users WHERE mail = '" . $user->getMail() . "'"; $userBdd = DBOperation::getOne($sQuery); if ($userBdd) { if (password_verify($user->getPassword(), $userBdd["password"])) { return new User($userBdd["id"], $userBdd["mail"], $userBdd["password"], false, $userBdd["firstname"], $userBdd["lastname"], $userBdd["address"], $userBdd["cp"], $userBdd["city"], $userBdd["phone"], $userBdd["role"]); } return false; } else { return false; } }
public static function get(Product $oProduct, User $oUser) { $sQuery = " select * from comment "; $sQuery .= " where product_id = " . $oProduct->getId() . " AND user_email = '" . $oUser->getEmail() . "'"; $sQuery .= " limit 1"; $aCommentRow = DBOperation::getOne($sQuery); $oComment = null; if (false !== $aCommentRow) { $oComment = self::convertToObject($aCommentRow); } return $oComment; }