本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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";
示例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
示例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;
}
示例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);
}