本文整理匯總了PHP中Vote::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP Vote::write方法的具體用法?PHP Vote::write怎麽用?PHP Vote::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Vote
的用法示例。
在下文中一共展示了Vote::write方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: add
/**
* Adds vote to the db.
*
* @return Vote data.
*/
protected function add() {
if($this->isAjax) {
$args = array(
'Choice' => Director::urlParam('Vote'),
'IP' => Director::urlParam('IP')
);
$vote = new Vote($args);
if($vote->write()) {
$args['success'] = true;
} else {
$args['success'] = false;
}
$json = json_encode($args);
return $json;
} else {
return Director::redirect('/');
}
}
示例2: registervote
public function registervote()
{
$pos = $_GET['pos'] == "true" ? true : false;
$roomid = Convert::raw2sql($_GET['roomid']);
$optionid = Convert::raw2sql($_GET['optionid']);
$nonce = $_POST["payment_method_nonce"];
$option = Option::get_by_id("Option", $optionid);
if (isset($_POST["payment_method_nonce"])) {
$result = Braintree_Transaction::sale(['amount' => '1.00', 'paymentMethodNonce' => $nonce]);
}
if ($option) {
$vote = new Vote();
$vote->Positive = $pos;
$vote->ParentID = $option->ID;
$voteID = $vote->write();
}
}