本文整理汇总了PHP中Recipe::setCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP Recipe::setCategory方法的具体用法?PHP Recipe::setCategory怎么用?PHP Recipe::setCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Recipe
的用法示例。
在下文中一共展示了Recipe::setCategory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
function build($line) {
$r = new Recipe();
$r->id = $line['id'];
$r->setTitle($line['title']);
$r->setOrigin($line['origin']);
$r->setSize($line['size']);
$r->setIngredients($line['ingredients']);
$r->setSteps($line['steps']);
$r->dateAdded = $line['date_added_ts'];
$r->hasPhoto = $line['has_photo'];
$r->rating = $line['rating'];
$r->authorId = $line['author_user_id'];
$catId = $line['category_id'];
if (strlen($catId) > 0) {
$cat = Category::getById($catId);
$r->setCategory($cat);
}
return $r;
}
示例2: Recipe
<? require_once("classes/Recipe.php"); ?>
<? require_once("classes/Text.php"); ?>
<?
$r = new Recipe();
$r->setTitle($_REQUEST['title']);
$r->setOrigin($_REQUEST['origin']);
$r->setSize($_REQUEST['size']);
$r->setIngredients($_REQUEST['ingredients']);
$r->setSteps($_REQUEST['steps']);
$cat = $_REQUEST['cat'];
if (strlen($cat) > 0) {
$c = Category::getById($cat);
$r->setCategory($c);
}
if (!Recipe::havePermission("ADD")) {
$errMsg=Text::getText("You are not allowed to add recipes.");
include("error.php");
exit;
}
$action = $_REQUEST['action'];
if ($action == "save" && Recipe::havePermission("ADD")) {
if ($_REQUEST['title'] != "") {
if ($_FILES['photo']['size'] != 0) {
$filename = $_FILES['photo']['name'];
$extension = strrchr($filename, '.');
if ($extension != ".jpg") {
$r->insert();