Example #1
0
 public function load($iUserID)
 {
     $connection = new Connection();
     $sSQL = "SELECT UserID, FirstName, LastName, Username, Address, Email, Telephone, Password, Admin\n                     FROM tbuser\n                     WHERE UserID=" . $iUserID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     //store data into attributes:
     $this->iUserID = $row['UserID'];
     $this->sFirstName = $row['FirstName'];
     $this->sLastName = $row['LastName'];
     $this->sUsername = $row['Username'];
     $this->sAddress = $row['Address'];
     $this->sEmail = $row['Email'];
     $this->iTelephone = $row['Telephone'];
     $this->sPassword = $row['Password'];
     $this->iAdmin = $row['Admin'];
     // get all recipe ids of each user:
     $sSQL = "SELECT RecipeID\n                     FROM tbrecipe\n                     WHERE UserID=" . $iUserID;
     $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();
 }
Example #2
0
 public static function get_makes()
 {
     //open connection to MySql
     parent::open_connection();
     //initialize arrays
     $ids = array();
     //array for ids
     $list = array();
     //array for objects
     //query
     $query = "select mak_id from makes";
     //prepare command
     $command = parent::$connection->prepare($query);
     //execute command
     $command->execute();
     //link results
     $command->bind_result($id);
     //fill ids array
     while ($command->fetch()) {
         array_push($ids, $id);
     }
     //close command
     mysqli_stmt_close($command);
     //close connection
     parent::close_connection();
     //fill object array
     for ($i = 0; $i < count($ids); $i++) {
         array_push($list, new Make($ids[$i]));
     }
     //return array
     return $list;
 }
Example #3
0
 function __construct()
 {
     if (func_num_args() == 0) {
         $this->id = '';
         $this->name = '';
         $this->description = '';
         $this->dosification = '';
         $this->peridiocity = "";
     }
     if (func_num_args() == 1) {
         $args = func_get_args();
         $id = $args[0];
         parent::open_connection();
         $query = "select schedule_id, schedule_name, schedule_note from Activities_Schedule where schedule_id = ?";
         $command = parent::$connection->prepare($query);
         $command->bind_param('s', $id);
         $command->execute();
         $command->bind_result($this->id, $this->name, $this->description);
         $found = $command->fetch();
         mysqli_stmt_close($command);
         parent::close_connection();
         if (!$found) {
             throw new RecordNotFoundException();
         }
     }
 }
 public function load($iSubscriberID)
 {
     $connection = new Connection();
     $sSQL = "SELECT SubscriberID, Email\n                     FROM tbnewsletter\n                     WHERE SubscriberID=" . $iSubscriberID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     //store data into attributes:
     $this->iSubscriberID = $row['SubscriberID'];
     $this->sEmail = $row['Email'];
     $connection->close_connection();
 }
Example #5
0
 public function load($iLikeID)
 {
     $connection = new Connection();
     $sSQL = "SELECT LikeID, UserID, RecipeID\n\t\t\t         FROM tblike\n\t\t\t         WHERE LikeID = " . $iLikeID;
     $resultSet = $connection->query($sSQL);
     $row = $connection->fetch_array($resultSet);
     // store into attributes:
     $this->iLikeID = $row["LikeID"];
     $this->iUserID = $row["UserID"];
     $this->iRecipeID = $row["RecipeID"];
     $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;
 }
 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;
 }
 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 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 #10
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 #11
0
 public function get_childs()
 {
     parent::open_connection();
     $ids = array();
     $list = array();
     $query = "select child_id from Therapies_Therapy_Child where therapy_id = ?";
     $command = parent::$connection->prepare($query);
     $command->bind_param('s', $this->id);
     $command->execute();
     $command->bind_result($id);
     while ($command->fetch()) {
         array_push($ids, $id);
     }
     mysqli_stmt_close($command);
     parent::close_connection();
     for ($i = 0; $i < count($ids); $i++) {
         array_push($list, new Child($ids[$i]));
     }
     return $list;
 }
Example #12
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 #13
0
 public function save()
 {
     $oConnection = new Connection();
     if ($this->bExisting == false) {
         $sSQL = "INSERT INTO tbcustomer(FirstName, LastName, Address, Telephone, Email, UserName, Password\n\t\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t'" . $oConnection->escape_value($this->sFirstName) . "',\n\t\t\t\t'" . $oConnection->escape_value($this->sLastName) . "',\n\t\t\t\t'" . $oConnection->escape_value($this->sAddress) . "',\n\t\t\t\t'" . $oConnection->escape_value($this->sTelephone) . "',\n\t\t\t\t'" . $oConnection->escape_value($this->sEmail) . "',\n\t\t\t\t'" . $oConnection->escape_value($this->sUserName) . "',\n\t\t\t\t'" . $oConnection->escape_value($this->sPassword) . "'\n\t\t\t\t)";
         $bResult = $oConnection->query($sSQL);
         if ($bResult == true) {
             $this->iCustomerID = $oConnection->get_insert_id();
             $this->bExisting = true;
         } else {
             die($sSQL . "failed");
         }
     } else {
         // updating current customer
         $sSQL = "UPDATE tbcustomer\n\t\t\tSET FirstName = '" . $oConnection->escape_value($this->sFirstName) . "', \n\t\t\tLastName = '" . $oConnection->escape_value($this->sLastName) . "',\n\t\t\tAddress = '" . $oConnection->escape_value($this->sAddress) . "', \n\t\t\tTelephone = '" . $oConnection->escape_value($this->sTelephone) . "',\n\t\t\tEmail = '" . $oConnection->escape_value($this->sEmail) . "',\n\t\t\tUserName = '******',\n\t\t\tPassword = '******'\n\t\t\tWHERE tbcustomer.CustomerID =" . $oConnection->escape_value($this->iCustomerID);
         $bResult = $oConnection->query($sSQL);
         if ($bResult == false) {
             die($sSQL . "fails");
         }
     }
     $oConnection->close_connection();
 }
Example #14
0
 function __construct()
 {
     //if no arguments received, create empty object
     if (func_num_args() == 0) {
         $this->id = '';
         $this->name = '';
         $this->password = '';
     }
     //if two argument received create object with data
     if (func_num_args() == 2) {
         //receive arguments into an array
         $args = func_get_args();
         //get arguments
         $id = $args[0];
         $password = $args[1];
         //open connection to MySql
         parent::open_connection();
         //query
         $query = "select usr_id, usr_name from users\n\t\t\t\t\t\t\t\t\twhere usr_id = ? and usr_password = sha1(?);";
         //prepare command
         $command = parent::$connection->prepare($query);
         //link parameters
         $command->bind_param('ss', $id, $password);
         //execute command
         $command->execute();
         //link results to class attributes
         $command->bind_result($this->id, $this->name);
         //fetch data
         $found = $command->fetch();
         //close command
         mysqli_stmt_close($command);
         //close connection
         parent::close_connection();
         //if not found throw exception
         if (!$found) {
             throw new RecordNotFoundException();
         }
     }
 }
Example #15
0
 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();
 }
Example #16
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();
 }
Example #17
0
 function __construct()
 {
     if (func_num_args() == 0) {
         $this->id = '';
         $this->name = '';
     }
     if (func_num_args() == 1) {
         $args = func_get_args();
         $id = $args[0];
         parent::open_connection();
         $query = "select day_id, day_name from Activities_Days where day_id = ?";
         $command = parent::$connection->prepare($query);
         $command->bind_param('i', $id);
         $command->execute();
         $command->bind_result($this->id, $this->name);
         $found = $command->fetch();
         mysqli_stmt_close($command);
         parent::close_connection();
         if (!$found) {
             throw new RecordNotFoundException();
         }
     }
 }
Example #18
0
 function __construct()
 {
     //if no arguments received, create empty object
     if (func_num_args() == 0) {
         $this->id = '';
         $this->description = '';
     }
     //if one argument received create object with data
     if (func_num_args() == 1) {
         //receive arguments into an array
         $args = func_get_args();
         //id
         $id = $args[0];
         //open connection to Mysql
         parent::open_connection();
         //query
         $query = "select pos_id, pos_description from positions where pos_id = ?";
         //prepare command
         $command = parent::$connection->prepare($query);
         //link parameters
         $command->bind_param('s', $id);
         //execute command
         $command->execute();
         //link results to class attributes
         $command->bind_result($this->id, $this->description);
         //fetch data
         $found = $command->fetch();
         //close command
         mysqli_stmt_close($command);
         //close connection
         parent::close_connection();
         //if not found throw exception
         if (!$found) {
             throw new RecordNotFoundException();
         }
     }
 }
Example #19
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 #20
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();
 }
Example #21
0
 function get_car_count($min_year, $max_year, $min_price, $max_price)
 {
     //open connection to MySql
     parent::open_connection();
     //query
     $query = 'select count(*) from cars where car_id_model = ?';
     if ($min_year != null) {
         $query .= ' and car_year >= ' . $min_year;
     }
     if ($max_year != null) {
         $query .= ' and car_year <= ' . $max_year;
     }
     if ($min_price != null) {
         $query .= ' and car_price >= ' . $min_price;
     }
     if ($max_price != null) {
         $query .= ' and car_price <= ' . $max_price;
     }
     //prepare command
     $command = parent::$connection->prepare($query);
     //parameters
     $command->bind_param('s', $this->id);
     //execute command
     $command->execute();
     //link results
     $command->bind_result($count);
     //read count
     $command->fetch();
     //close command
     mysqli_stmt_close($command);
     //close connection
     parent::close_connection();
     //return count
     return $count;
 }
Example #22
0
 function get_teams()
 {
     //open connection to Mysql
     parent::open_connection();
     //initialize array_sum
     $ids = array();
     //array for ids
     $list = array();
     //array for objects
     //query
     $query = "select team_id from teams where team_id_div = ?";
     //prepare command
     $command = parent::$connection->prepare($query);
     //link parameters
     $command->bind_param('s', $this->id);
     //execute command
     $command->execute();
     //link results
     $command->bind_result($id);
     //fill ids array
     while ($command->fetch()) {
         array_push($ids, $id);
     }
     //close command
     mysqli_stmt_close($command);
     //close connection
     parent::close_connection();
     //fill object array
     for ($i = 0; $i < count($ids); $i++) {
         array_push($list, new Team($ids[$i]));
     }
     //return array
     return $list;
 }
Example #23
0
 public function get_activities()
 {
     parent::open_connection();
     $ids = array();
     $list = array();
     $query = "select schedule_id from Activities_Schedule_Days where schedule_id = ?";
     $command = parent::$connection->prepare($query);
     $command->bind_param('i', $this->id);
     $command->execute();
     $command->bind_result($id);
     while ($command->fetch()) {
         array_push($ids, $id);
     }
     mysqli_stmt_close($command);
     parent::close_connection();
     for ($i = 0; $i < count($ids); $i++) {
         array_push($list, new Activity($ids[$i]));
     }
     return $list;
 }
Example #24
0
 public function get_dosification()
 {
     parent::open_connection();
     $query = "select dosification from Medicines_Medicine_Child where medicine_id = ?";
     $command = parent::$connection->prepare($query);
     $command->bind_param('s', $this->id);
     $command->execute();
     $command->bind_result($id);
     $command->fetch();
     mysqli_stmt_close($command);
     parent::close_connection();
     return $id;
 }
Example #25
0
 public function get_transporter()
 {
     parent::open_connection();
     $query = "select child_transporter_id from Persons_Child where child_tutor_id = ?";
     $command = parent::$connection->prepare($query);
     $command->bind_param('s', $this->id);
     $command->execute();
     $command->bind_result($id);
     $command->fetch();
     mysqli_stmt_close($command);
     parent::close_connection();
     return $id;
 }