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(); }
foreach ($penList as $content) { if ($content->priority < $config->priority && $content->priority > $prev->priority) { $prev = $content; } if ($content->priority > $config->priority && $content->priority < $succ->priority) { $succ = $content; } } srkSend((object) array('prev' => $prev->penId, 'succ' => $succ->penId)); } } } elseif ($srkEnv->reqURL[2] == 'like' && $srkEnv->reqMethod == 'POST') { $like = new Like(); if ($srkEnv->reqURLLength == 4) { $penId = $srkEnv->reqURL[4]; $like->load($srkEnv->penPath . '/' . $penId); } elseif ($srkEnv->reqURLLength == 5) { $penId = $srkEnv->reqURL[4]; $commentId = $srkEnv->reqURL[5]; $like->load($srkEnv->penPath . '/' . $penId . '/comment/' . $commentId); } if ($srkEnv->reqURL[3] == 'query') { srkSend($like->query()); } elseif (isset(Like::$actionMap[$srkEnv->reqURL[3]])) { $userId = $_SESSION['userId']; if (!$userId) { srkSend((object) array('error' => 'login')); } else { srkSend((object) array('error' => $like->click($userId, Like::$actionMap[$srkEnv->reqURL[3]]))); } }