当前位置: 首页>>代码示例>>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;未经允许,请勿转载。