本文整理汇总了PHP中Recipe::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Recipe::search方法的具体用法?PHP Recipe::search怎么用?PHP Recipe::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Recipe
的用法示例。
在下文中一共展示了Recipe::search方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Function for recipe search (From POST parameteres)
*
* If POST parameters are sent, then perform search
* If no POST parameters exist in the HTTP request, display the search controls/form
*
* @param: None
* @return: None
*/
public function search(){
//Test if the POST parameters exist. If they don't present the user with the
//search controls/form
if(!isset($_POST["search"])){
$this->template->display('search.html.php');
}
//Get the recipe from the database
$recipes = Recipe::search($_POST["search"]);
//If successful and the count is equal to one (as desired)
//set the recipe object in the template to be displayed
$this->template->recipes = $recipes;
$this->template->display('results.html.php');
}
示例2: require_once
require_once("classes/Category.php");
require_once("classes/Recipe.php");
$q = $_REQUEST['q'];
$cat = $_REQUEST['cat'];
if ($q != NULL) {
$searched .= Text::getText("SearchedFor")." <b>".$q."</b>";
if ($cat != NULL) {
$c = Category::getById($cat);
$searched .= " ".Text::getText("in")." <b>".$c->getName()."</b>";
}
$recipes = Recipe::search($q, $c);
} else if ($cat != NULL) {
$c = Category::getById($cat);
$searched .= Text::getText("Category").": <b>".$c->getName()."</b>";
$recipes = Recipe::search("", $c);
}
if ($recipes != null && count($recipes) == 1) {
header("Location: ".$recipes[0]->href());
exit;
}
$output = $_REQUEST['output'];
if ($output != "json") {
include("header.php");
?><h2><?php
echo Text::getText("Search");
?>
</h2><?
}