public function load($iRecipeTypeID)
 {
     $connection = new Connection();
     $sSQL = "SELECT RecipeTypeID, TypeName, Description, DisplayOrder\n                     FROM tbrecipetype\n                     WHERE RecipeTypeID=" . $iRecipeTypeID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     //store into data attribues:
     $this->iRecipeTypeID = $row["RecipeTypeID"];
     $this->sTypeName = $row["TypeName"];
     $this->sDescription = $row["Description"];
     $this->iDisplayOrder = $row["DisplayOrder"];
     // get all recipe IDs of type:
     $sSQL = "SELECT RecipeID\n                     FROM tbrecipe\n                     WHERE RecipeTypeID=" . $iRecipeTypeID . "\n                     ORDER BY CreatedAt DESC";
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iRecipeID = $row['RecipeID'];
         $oRecipe = new Recipe();
         $oRecipe->load($iRecipeID);
         $this->aRecipes[] = $oRecipe;
     }
     $connection->close_connection();
 }
 public static function listAllTypes()
 {
     // creates associative array
     $aRecipeTypes = array();
     $connection = new Connection();
     $sSQL = "SELECT RecipeTypeID,TypeName\n                     FROM tbrecipetype\n                     ";
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iRecipeTypeID = $row['RecipeTypeID'];
         $aRecipeTypes[$iRecipeTypeID] = $row['TypeName'];
     }
     $connection->close_connection();
     return $aRecipeTypes;
 }
Example #3
0
 public function load($iCommentID)
 {
     $connection = new Connection();
     $sSQL = "SELECT CommentID, Comment, UserID, RecipeID, CreatedAt, OriginalID\n                     FROM tbcomment\n                     WHERE CommentID=" . $iCommentID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     //store data into attributes:
     $this->iCommentID = $row["CommentID"];
     $this->sComment = $row["Comment"];
     $this->iUserID = $row["UserID"];
     $this->iRecipeID = $row["RecipeID"];
     $this->tCreatedAt = $row["CreatedAt"];
     $this->iOriginalID = $row["OriginalID"];
     $sSQL = "SELECT CommentID \n                    FROM tbcomment\n                    WHERE OriginalID=" . $iCommentID;
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iCommentID = $row["CommentID"];
         $oComment = new Comment();
         $oComment->load($iCommentID);
         $this->aReplies[] = $oComment;
     }
     $connection->close_connection();
 }
 public static function getAllProducts()
 {
     $aAllProducts = array();
     $connection = new Connection();
     $sSQL = "SELECT ProductID\n                     FROM tbproduct\n                     ORDER BY CreatedAt DESC\n                     ";
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iProductID = $row['ProductID'];
         $oProduct = new Product();
         $oProduct->load($iProductID);
         $aAllProducts[] = $oProduct;
     }
     $connection->close_connection();
     return $aAllProducts;
 }
Example #5
0
 public function load($iRecipeID)
 {
     $connection = new Connection();
     $sSQL = "SELECT RecipeID, Title, AuthorNotes, Ingredients, Directions, ImagePath, CreatedAt, UserID, RecipeTypeID\n                     FROM tbrecipe\n                     WHERE RecipeID = " . $iRecipeID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     //store into attributes:
     $this->iRecipeID = $row["RecipeID"];
     $this->sTitle = $row["Title"];
     $this->sAuthorNotes = $row["AuthorNotes"];
     $this->sIngredients = $row["Ingredients"];
     $this->sDirections = $row["Directions"];
     $this->sImagePath = $row["ImagePath"];
     $this->tCreatedAt = $row["CreatedAt"];
     $this->iUserID = $row["UserID"];
     $this->iRecipeTypeID = $row["RecipeTypeID"];
     // get all likes from recipe:
     $sSQL = "SELECT LikeID\n                     FROM tblike\n                     WHERE RecipeID = " . $iRecipeID;
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iLikeID = $row["LikeID"];
         $oLike = new Like();
         $oLike->load($iLikeID);
         $this->aLikes[] = $iLikeID;
     }
     // get all comments on a recipe:
     $sSQL = "SELECT CommentID\n                    FROM tbcomment\n                    WHERE RecipeID = " . $iRecipeID . " ORDER BY CreatedAt DESC";
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iCommentID = $row["CommentID"];
         $oComment = new Comment();
         $oComment->load($iCommentID);
         $this->aComments[] = $oComment;
     }
     $connection->close_connection();
 }
Example #6
0
 public function loadByUserRecipe($iUserID, $iRecipeID)
 {
     // checks if user has already liked recipe
     $connection = new Connection();
     $sSQL = "SELECT LikeID\n\t\t\t\t     FROM tblike\n\t\t\t\t     WHERE UserID='" . $connection->escape($iUserID) . "' AND RecipeID='" . $connection->escape($iRecipeID) . "'";
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     if ($row == false) {
         // user hasn't liked recipe
         return false;
     } else {
         $this->load($row["LikeID"]);
         return true;
     }
 }
Example #7
0
 public function load($iID)
 {
     // open
     $oConnection = new Connection();
     // extract
     $sSQL = "SELECT TypeID, TypeName, Description, DisplayOrder\n\t\tFROM tbproducttype\n\t\tWHERE TypeID=" . $iID;
     $oResult = $oConnection->query($sSQL);
     // fetch
     $aCategory = $oConnection->fetch_array($oResult);
     $this->iTypeID = $aCategory["TypeID"];
     $this->sTypeName = $aCategory["TypeName"];
     $this->sDescription = $aCategory["Description"];
     $this->iDisplayOrder = $aCategory["DisplayOrder"];
     // load products under the category
     $sSQL = "SELECT ProductID\n\t\tFROM tbproduct\n\t\tWHERE TypeID=" . $iID;
     $oResult = $oConnection->query($sSQL);
     while ($aRow = $oConnection->fetch_array($oResult)) {
         $oProduct = new product();
         $oProduct->load($aRow["ProductID"]);
         $this->aProducts[] = $oProduct;
     }
     // close
     $oConnection->close_connection();
 }
 public static function getAllRecipes()
 {
     $aAllRecipes = array();
     $connection = new Connection();
     $sSQL = "SELECT RecipeID\n                     FROM tbrecipe\n                     ORDER BY CreatedAt DESC\n                     ";
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iRecipeID = $row['RecipeID'];
         $oRecipe = new Recipe();
         $oRecipe->load($iRecipeID);
         $aAllRecipes[] = $oRecipe;
     }
     $connection->close_connection();
     return $aAllRecipes;
 }
Example #9
0
 public function loadByUsername($sUsername)
 {
     // checks if username already exists in database
     $connection = new Connection();
     $sSQL = "SELECT UserID\n                     FROM tbuser\n                     WHERE Username='******'";
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     if ($row == false) {
         // if username doesn't exist
         return false;
     } else {
         $this->load($row["UserID"]);
         // if username exists
         return true;
     }
 }
Example #10
0
 public function loadByEmail($sEmail)
 {
     // checks if email already exists in database
     $connection = new Connection();
     $sSQL = "SELECT SubscriberID\n                     FROM tbnewsletter\n                     WHERE Email='" . $connection->escape($sEmail) . "'";
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     if ($row == false) {
         // if user hasn't subscribed
         return false;
     } else {
         $this->load($row['SubscriberID']);
         // if user has already subscribed
         return true;
     }
 }
Example #11
0
 public function load($iProductID)
 {
     $connection = new Connection();
     $sSQL = "SELECT ProductID, ProductName, Description, Price, Size, Ingredients, StockLevel, ImagePath, CreatedAt\n                     FROM tbproduct\n                     WHERE ProductID=" . $iProductID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     //store into attributes:
     $this->iProductID = $row["ProductID"];
     $this->sProductName = $row["ProductName"];
     $this->sDescription = $row["Description"];
     $this->fPrice = $row["Price"];
     $this->sSize = $row["Size"];
     $this->sIngredients = $row["Ingredients"];
     $this->iStockLevel = $row["StockLevel"];
     $this->sImagePath = $row["ImagePath"];
     $this->tCreatedAt = $row["CreatedAt"];
     $connection->close_connection();
 }
Example #12
0
 public function load($iID)
 {
     // Open
     $oConnection = new Connection();
     // Extract
     $sSQL = "SELECT ProductID, ProductName, Description, Price, TypeID, PhotoPath\n\t\tFROM tbproduct\n\t\tWHERE ProductID =" . $iID;
     $oResult = $oConnection->query($sSQL);
     // fetch
     $aProduct = $oConnection->fetch_array($oResult);
     $this->iProductID = $aProduct["ProductID"];
     $this->sProductName = $aProduct["ProductName"];
     $this->sDescription = $aProduct["Description"];
     $this->iCost = $aProduct["Price"];
     $this->iTypeID = $aProduct["TypeID"];
     $this->sPhotoPath = $aProduct["PhotoPath"];
     // close
     $oConnection->close_connection();
 }
Example #13
0
 public function load($iOrderID)
 {
     $connection = new Connection();
     $sSQL = "SELECT OrderID, OrderDate, OrderStatus, RecipientName, DeliveryAddress, BillingAddress, Payment, AccountName, CardNumber, ExpiryDate, Security, UserID\n                     FROM tborder\n                     WHERE OrderID=" . $iOrderID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     //store data in attributes:
     $this->iOrderID = $row["OrderID"];
     $this->tOrderDate = $row["OrderDate"];
     $this->sOrderStatus = $row["OrderStatus"];
     $this->sRecipientName = $row["RecipientName"];
     $this->sDelivery = $row["DeliveryAddress"];
     $this->sBilling = $row["BillingAddress"];
     $this->sPayment = $row["Payment"];
     $this->sAccountName = $row["AccountName"];
     $this->iCardNumber = $row["CardNumber"];
     $this->sExpiry = $row["ExpiryDate"];
     $this->iSecurity = $row["Security"];
     $this->iUserID = $row["UserID"];
     $connection->close_connection();
 }
Example #14
0
 public function load($iID)
 {
     // open
     $oConnection = new Connection();
     // execute query
     $sSQL = "SELECT CustomerID, FirstName, LastName, Address, Telephone, Email, Username, Password\n\t\tFROM tbcustomer\n\t\tWHERE CustomerID =" . $oConnection->escape_value($iID);
     $oResult = $oConnection->query($sSQL);
     // extract
     $aCustomer = $oConnection->fetch_array($oResult);
     $this->iCustomerID = $aCustomer["CustomerID"];
     $this->sFirstName = $aCustomer["FirstName"];
     $this->sLastName = $aCustomer["LastName"];
     $this->sAddress = $aCustomer["Address"];
     $this->sTelephone = $aCustomer["Telephone"];
     $this->sEmail = $aCustomer["Email"];
     $this->sUserName = $aCustomer["Username"];
     $this->sPassword = $aCustomer["Password"];
     $this->bExisting = true;
     // close
     $oConnection->close_connection();
 }