本文整理匯總了PHP中Preference::getAllPreferenceByUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Preference::getAllPreferenceByUser方法的具體用法?PHP Preference::getAllPreferenceByUser怎麽用?PHP Preference::getAllPreferenceByUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Preference
的用法示例。
在下文中一共展示了Preference::getAllPreferenceByUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: dirname
require_once dirname(__FILE__) . "/php/class.preference.php";
global $bdd;
global $_TABLES;
$content = "";
$view = new Template(dirname(__FILE__) . '/html/category.html');
if (!is_null($bdd) && !is_null($_TABLES)) {
$objCategory = new Category($bdd, $_TABLES);
$categories = $objCategory->getAllCategories();
if (!is_null($categories)) {
if (isset($_COOKIE['category_preference'])) {
unset($_COOKIE['category_preference']);
}
$preferences = array();
if (isset($_SESSION['user_id'])) {
$objPreference = new Preference($bdd, $_TABLES);
$items = $objPreference->getAllPreferenceByUser($_SESSION['user_id']);
if (!is_null($items)) {
foreach ($items as $key => $item) {
array_push($preferences, $item->category_id);
}
}
$json = json_encode($preferences);
setcookie('user_preference', $json, -1, "/");
}
foreach ($categories as $key => $value) {
if ($preferences != null) {
$checked = in_array($value->id, $preferences) == true ? 'checked="true"' : '';
} else {
$checked = '';
}
$content .= $view->getView(array("category_id" => $value->id, "category_name" => mb_strtoupper($value->category, 'UTF-8'), "checked" => $checked));