本文整理汇总了PHP中Feedback::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Feedback::add方法的具体用法?PHP Feedback::add怎么用?PHP Feedback::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feedback
的用法示例。
在下文中一共展示了Feedback::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
示例2: htmlspecialchars
} else {
$response = 'response';
}
if (isset($_POST['mark'])) {
$mark = htmlspecialchars(trim($_POST['mark']));
} else {
$mark = '';
}
if (isset($_POST['good'])) {
$good = htmlspecialchars(trim($_POST['good']));
} else {
$good = '';
}
if (isset($_POST['better'])) {
$better = htmlspecialchars(trim($_POST['better']));
} else {
$better = '';
}
$auth = new Auth();
if (isset($_POST['send'])) {
$auth->setSession();
}
//hasSession проверяет существует ли $_SESSION['resp']==1 и увеличивает её на 1
if ($auth->hasSession()) {
$feed = new Feedback();
$arr = $feed->add($name, $email, $response, $shotdate, $mark, $good, $better);
include __DIR__ . '/views/single.php';
} else {
header('Location: ./');
}
}
示例3: getCurlData
continue;
}
$id_product = array_rand($productids);
$feedback = new Feedback();
$feedback->id_product = (int) $id_product;
$feedback->unit_price = (double) $productids[$id_product];
$feedback->quantity = (int) $feed->quantity;
$feedback->md5_key = md5(time());
$feedback->flag_code = strtolower($feed->countryCode);
$feedback->name = substr($feed->name, 0, 1) . "***" . substr($feed->name, -2, 2);
$feedback->feedback = pSQL($feed->buyerFeedback);
$feedback->id_user = 0;
$feedback->rating = (int) $feed->star;
$feedback->active = 1;
$feedback->add_date = rand_time(Tools::getRequest('from_date'));
if ($feedback->add()) {
$field = pSQL($rating_fields[$feed->star - 1]);
if ($feedback->feedbackStateExists($id_product)) {
Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'feedback_state SET times=times+1,total_rating=total_rating+' . (int) $feedback->rating . ",`" . $field . "`=`" . $field . "`+1 \n\t\t\t\tWHERE id_product=" . intval($id_product));
} else {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'feedback_state SET id_product=' . intval($id_product) . ',times=1,total_rating=' . (int) $feedback->rating . ",`" . $field . "`=`" . $field . "`+1");
}
Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'product SET orders=orders+' . rand(3, 5) . ' WHERE id_product=' . (int) $id_product);
}
}
}
function getCurlData($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);