當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Recipe類代碼示例

本文整理匯總了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;
 }
開發者ID:elifah93,項目名稱:Internet-Programming,代碼行數:26,代碼來源:Recipe.php

示例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();
 }
開發者ID:leanne-abarro,項目名稱:getInMyBelly,代碼行數:27,代碼來源:user.php

示例3: testIfObjectRetunsListOfRecipes

 function testIfObjectRetunsListOfRecipes()
 {
     $recipe = new Recipe(1);
     $user = new User(1);
     $starredRecipe = new StarredRecipe($user->id(), $recipe->id());
     $this->assertTrue(!empty($starredRecipe->recipes()));
 }
開發者ID:VedranBrnjetic,項目名稱:BBCTestRecipe,代碼行數:7,代碼來源:starredRecipe_test.php

示例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);
 }
開發者ID:vishaleyes,項目名稱:cookingwithzend,代碼行數:34,代碼來源:StarRating.php

示例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'));
 }
開發者ID:y2khjh,項目名稱:test1,代碼行數:9,代碼來源:RecipeTest.php

示例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;
 }
開發者ID:xavidram,項目名稱:RecipeListPHP,代碼行數:9,代碼來源:Step.php

示例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;
 }
開發者ID:bolivarez9193,項目名稱:Brandons_Repo,代碼行數:12,代碼來源:Recipe.php

示例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>";
}
開發者ID:realsoc,項目名稱:SemanticProjectGraph,代碼行數:12,代碼來源:SemanticProjectGraph.php

示例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;
 }
開發者ID:bolivarez9193,項目名稱:Brandons_Repo,代碼行數:12,代碼來源:Recipe.php

示例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;
     }
 }
開發者ID:geoffhumphrey,項目名稱:brewblogger,代碼行數:13,代碼來源:parse_beer_xml.inc.php

示例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;
 }
開發者ID:leanne-abarro,項目名稱:getInMyBelly,代碼行數:15,代碼來源:recipeManager.php

示例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);
 }
開發者ID:JoshRamynke,項目名稱:MealPlan-Web,代碼行數:13,代碼來源:RecipeController.php

示例13: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Recipe::create([]);
     }
 }
開發者ID:Defoncesko,項目名稱:iamhungry,代碼行數:7,代碼來源:RecipesTableSeeder.php

示例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;
 }
開發者ID:RobinDumontChaponet,項目名稱:cocktails,代碼行數:15,代碼來源:RecipeDAO.class.php

示例15: sandbox

 public static function sandbox()
 {
     $first = Recipe::find(1);
     $recipes = Recipe::all();
     Kint::dump($recipes);
     Kint::dump($first);
 }
開發者ID:emivo,項目名稱:Tsoha-Bootstrap,代碼行數:7,代碼來源:sandbox_controller.php


注:本文中的Recipe類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。