本文整理汇总了PHP中Feedback::haveFeedbackWithUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Feedback::haveFeedbackWithUser方法的具体用法?PHP Feedback::haveFeedbackWithUser怎么用?PHP Feedback::haveFeedbackWithUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feedback
的用法示例。
在下文中一共展示了Feedback::haveFeedbackWithUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayMain
public function displayMain()
{
global $smarty, $link, $cookie;
if (!$cookie->logged) {
Tools::redirect($link->getPage('LoginView'));
}
$user = new User((int) $cookie->id_user);
$errors = array();
$success = false;
//添加feedback
//1.添加创建对象
if (Tools::isSubmit('submit')) {
$feedback = new Feedback();
$feedback->copyFromPost();
if ($feedback->rating <= 0 && $feedback->rating > 5) {
$feedback->rating = 4;
}
$data = explode("-", base64_decode(Tools::getRequest("data")));
$feedback->id_product = (int) $data[0];
$feedback->unit_price = (double) $data[2];
$feedback->quantity = (int) $data[3];
$feedback->md5_key = md5(Tools::getRequest("data"));
$feedback->name = substr($user->first_name, 0, 1) . "***" . substr($user->last_name, -1, 1);
$feedback->id_user = $user->id;
if ($feedback->add()) {
$success = true;
} else {
$errors = $feedback->_errors;
}
}
//2.获取用户评论过的MD5KEY
$proids = Feedback::haveFeedbackWithUser($user->id);
//3.获取用户购买过的产品
$products = array();
if ($result = $user->getPaymentedProduct()) {
foreach ($result as &$row) {
if (!in_array($row['md5_key'], $proids)) {
$products[] = $row;
}
}
}
$smarty->assign(array('success' => $success, 'errors' => $errors, 'products' => $products, 'DISPLAY_LEFT' => Module::hookBlock(array('myaccount'))));
return $smarty->fetch('my-feedback.tpl');
}