本文整理汇总了PHP中Recipe类的典型用法代码示例。如果您正苦于以下问题:PHP Recipe类的具体用法?PHP Recipe怎么用?PHP Recipe使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Recipe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findByKeyword
static function findByKeyword($dbh, $keyWord)
{
$keyWords = explode(" ", $keyWord);
// Split the string.
$strStmt = "select * from " . Recipe::$tableName . " where ";
for ($i = 0; $i < sizeof($keyWords); $i++) {
// Add the number of keyWords the user want to search.
if ($i > 0) {
$strStmt .= "AND ";
}
$strStmt .= "(Name LIKE :keyWord_" . $i . " OR Description LIKE :keyWord_" . $i . ")";
$keyWords[$i] = "%" . $keyWords[$i] . "%";
}
$stmt = $dbh->prepare($strStmt);
for ($i = 0; $i < sizeof($keyWords); $i++) {
$stmt->bindParam(":keyWord_" . $i, $keyWords[$i]);
}
$stmt->execute();
$result = array();
while ($row = $stmt->fetch()) {
$r = new Recipe();
$r->copyFromRow($row);
$result[] = $r;
}
return $result;
}
示例2: load
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();
}
示例3: testIfObjectRetunsListOfRecipes
function testIfObjectRetunsListOfRecipes()
{
$recipe = new Recipe(1);
$user = new User(1);
$starredRecipe = new StarredRecipe($user->id(), $recipe->id());
$this->assertTrue(!empty($starredRecipe->recipes()));
}
示例4: starRating
public function starRating($recipeId, $id = null, $value = null)
{
$session = Zend_Registry::get('session');
$log = Zend_Registry::get('log');
// fetch the rating
$ra = new Rating();
$rating = $ra->getRating($recipeId);
// If were passing through a value we already know what to display and are probably read only
if (isset($value)) {
return $this->displayRating($value, $id);
}
// Logged in?
if (!$session->user) {
return $this->displayRating($rating);
}
//$log->debug( $session->user['name'] . ' is logged in' );
$r = new Recipe();
if ($r->isOwner($recipeId)) {
return $this->displayRating($rating);
}
//$log->debug( $session->user['name'] . ' is not the owner' );
// Has this user already rated?
$db = Zend_Registry::get('db');
$select = $db->select()->from('ratings', array("numberOfRatings" => "COUNT(*)"))->where("recipe_id = ?", $recipeId)->where("user_id = ?", $session->user['id']);
//$log->debug( $select->__toString() );
//$log->debug( $db->fetchOne( $select ) );
// If we get a result show the user the overall rating
if ($db->fetchOne($select) > 0) {
return $this->displayRating($rating);
}
//$log->debug( $session->user['name'] . ' has not already rated this' );
// Otherwise show the rating but make it clickable
return $this->displayRating($rating, null, false);
}
示例5: testRecipeWhenValid
public function testRecipeWhenValid()
{
$name = 'bread with butter';
$ingredients = array(new Ingredient('bread', 1, 'slices', new DateTime('+30 day')), new Ingredient('butter', 1, 'slices', new DateTime('+15 day')));
$recipe = new Recipe($name, $ingredients);
$this->assertEquals($recipe->getName(), $name);
$this->assertEquals($recipe->getIngredients(), $ingredients);
$this->assertEquals($recipe->getEarliestUsedBy(), new DateTime('+15 day'));
}
示例6: findByName
function findByName($dbh, $keyword)
{
$stmt = $dbh->prepare("select * from " . Recipe::$tableName . " WHERE name LIKE '%" . $keyword . "%'");
$stmt->execute();
$row = $stmt->fetch();
$p = new Recipe();
$p->copyFromRow($row);
return $p;
}
示例7: findByKeyword
static function findByKeyword($dbh, $searchOne)
{
$stmt = $dbh->prepare("SELECT * FROM " . Recipe::$nameTable . " WHERE Name LIKE '%" . $searchOne . "%' AND Description LIKE '%" . $searchOne . "%'");
$stmt->execute();
$newResult = array();
while ($row = $stmt->fetch()) {
$r = new Recipe();
$r->copyFromRow($row);
$newResult[] = $r;
}
return $newResult;
}
示例8: SemanticRecipeGraphFunction_Render
function SemanticRecipeGraphFunction_Render($parser, $param1 = '')
{
$mProject = new Recipe($param1);
$dotStr = $mProject->retrieveAndGetCode();
doDot($param1, $dotStr);
$ret = htmlForImage($param1, 'recipe');
if ($ret == null) {
}
return array($ret, 'isHTML' => true);
//testing:
//return "<pre>$hgtext</pre>";
}
示例9: findAll
static function findAll($dbh)
{
$stmt = $dbh->prepare("select * from " . Recipe::$nameTable);
$stmt->execute();
$result = array();
while ($row = $stmt->fetch()) {
$r = new Recipe();
$r->copyFromRow($row);
$result[] = $r;
}
return $result;
}
示例10: startElement
function startElement($parser, $tagName, $attrs)
{
$this->tag = $tagName;
switch ($tagName) {
case "RECIPE":
$recipe = new Recipe();
$recipe->parse($parser, $this);
$this->recipes[] = $recipe;
break;
default:
break;
}
}
示例11: getAllRecipes
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;
}
示例12: getEdit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function getEdit($id)
{
// get the recipe
$recipe = Recipe::find($id);
// show the edit form and pass the recipe
return View::make('recipe.edit')->with('recipe', $recipe);
}
示例13: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Recipe::create([]);
}
}
示例14: getById
/**
* getById function. Get Recipe Object by id in array. In fact it is only to use a more modern and convenient way to access data. For the sake of coherence !
*
* @access public
* @static
* @param int id - $id
* @return Recipe Object
*/
public static function getById($id)
{
if (Recipe::getDataAt($id)) {
return new Recipe($id);
}
return null;
}
示例15: sandbox
public static function sandbox()
{
$first = Recipe::find(1);
$recipes = Recipe::all();
Kint::dump($recipes);
Kint::dump($first);
}