当前位置: 首页>>代码示例>>PHP>>正文


PHP Recipe::copyFromRow方法代码示例

本文整理汇总了PHP中Recipe::copyFromRow方法的典型用法代码示例。如果您正苦于以下问题:PHP Recipe::copyFromRow方法的具体用法?PHP Recipe::copyFromRow怎么用?PHP Recipe::copyFromRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Recipe的用法示例。


在下文中一共展示了Recipe::copyFromRow方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: Recipe

<?php

require_once "models/db.php";
require_once "models/Recipe.php";
$recipe = new Recipe();
if ($_POST) {
    $recipe->copyFromRow($_POST);
    if ($recipe->validate()) {
        $recipe->save($dbh);
        echo "save successfully";
        die;
    }
}
// default route, show page for adding
require_once "views/view_recipe.php";
开发者ID:elifah93,项目名称:Internet-Programming,代码行数:15,代码来源:AddRecipe.php

示例6: Recipe

$newRecipe->Name = "Soup";
$newRecipe->ID = 1000;
$newRecipe->Description = "It's Hot";
$newRecipe->Image = "haha no";
$newRecipe->Prep = "10:25";
$newRecipe->Total = "20:00";
$newRecipe->Rating = 5;
print $newRecipe;
?>
<br>
<br>
<?php 
// copyFromRow testing
$thisArray = ['ID' => 1001, 'Name' => "Bread", 'Description' => "It's Soft", 'Image' => "haha no", 'Prep' => "00:25", 'Total' => "05:00", 'Rating' => 4];
$recipe2 = new Recipe();
$recipe2->copyFromRow($thisArray);
print $recipe2;
?>
<br>
<br>
<?php 
// find testing
require_once "models/DB.php";
$recipe3 = new Recipe();
//$recipe3->ID = 1;
$recipe3->find(1, $dbh);
print $recipe3;
?>
<br>
<br>
<?php 
开发者ID:bolivarez9193,项目名称:Brandons_Repo,代码行数:31,代码来源:TestController.php

示例7: findByKeyword

 function findByKeyword($dbh, $keyword)
 {
     $stmt = $dbh->prepare("select * from " . Recipe::$tableName . " WHERE name LIKE  '%" . $keyword . "%' OR description LIKE '%" . $keyword . "%'");
     $stmt->execute();
     $result = array();
     while ($row = $stmt->fetch()) {
         $p = new Recipe();
         $p->copyFromRow($row);
         $result[] = $p;
     }
     return $result;
 }
开发者ID:xavidram,项目名称:RecipeListPHP,代码行数:12,代码来源:Recipe.php

示例8: header

$u = Unit::findAll($dbh);
$ing = Ingredient::findAll($dbh);
// Route 1: user comes here to add a new recipe, show them a blank form
$add = true;
// Route 2: user comes here to edit a specific recipe
//   (you'll need to grab that id from the query string)
if (isset($_GET['id'])) {
    $add = false;
    $recipes->find($_GET['id'], $dbh);
}
// Route 3a: user entered a new recipe details and is trying to save it
//   create an object, set values, validate and save, just like in the lab
//   if all is well, send to ShowRecipe to see the added recipe
//   otherwise, back to the edit view with errors!
if ($_POST && !$_GET) {
    $recipes->copyFromRow($_POST);
    if ($recipes->validate()) {
        $recipes->save($dbh);
        header('Location: RecipeList.php?id=' . $recipes->id);
    }
}
// Route 3b: user updated an existing recipe details and is trying to save it
//   create an object, inflate to the proper id, update values, validate and save
//   if all is well, send to ShowRecipe to see the added recipe
//   otherwise, back to the edit view with errors!
if ($_POST && $_GET) {
    $recipes->copyFromRow($_POST);
    if ($recipes->validate()) {
        $recipes->save($dbh);
        header('Location: RecipeList.php?id=' . $recipes->id);
    }
开发者ID:elifah93,项目名称:Internet-Programming,代码行数:31,代码来源:EditRecipe.php


注:本文中的Recipe::copyFromRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。