本文整理汇总了PHP中Poll::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Poll::create方法的具体用法?PHP Poll::create怎么用?PHP Poll::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poll
的用法示例。
在下文中一共展示了Poll::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_new
public static function action_new($id = null)
{
if ($id) {
return Response::error(404);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && Param::post('question')) {
$pregunta = Param::post('question');
$description = Param::post('description');
$various_answers = Param::post('various_answers');
$slug = Param::post('slug');
$answers = Param::post('new_answers');
if (empty($pregunta) || empty($description) || empty($slug) || count($answers) < 2) {
Redirect::to(Url::get('admin', null, 'poll_creation_error=true'));
}
$poll_id = Poll::create(array('question' => $pregunta, 'description' => $description, 'slug' => $slug, 'various_answers' => $various_answers));
foreach ($answers as $answer) {
Answer::create(array('poll_id' => $poll_id, 'text' => $answer));
}
Redirect::to(Url::get('admin', null, 'success=' . $poll_id . '&created=true'));
}
return View::make('admin.new');
}
示例2: foreach
$poll->setProperty('date_end', $f_date_end);
$poll->setProperty('votes_per_user', $f_votes_per_user);
$poll->setProperty('nr_of_answers', $f_nr_of_answers);
$poll->setProperty('is_extended', $f_is_extended);
foreach ($f_answers as $nr_answer => $text) {
if ($text !== '__undefined__') {
$answer = new PollAnswer($f_fk_language_id, $f_poll_nr, $nr_answer);
if ($answer->exists()) {
$answer->setProperty('answer', $text);
} else {
$answer->create($text);
}
}
}
PollAnswer::SyncNrOfAnswers($f_fk_language_id, $f_poll_nr);
} else {
// create new poll
$poll = new Poll($f_fk_language_id);
$success = $poll->create($f_title, $f_question, $f_date_begin, $f_date_end, $f_nr_of_answers, $f_votes_per_user);
if ($success) {
$poll->setProperty('is_extended', $f_is_extended);
foreach ($f_answers as $nr_answer => $text) {
if ($text !== '__undefined__') {
$answer = new PollAnswer($f_fk_language_id, $poll->getNumber(), $nr_answer);
$success = $answer->create($text);
}
}
}
}
$f_from = Input::Get('f_from', 'string', 'index.php');
camp_html_goto_page($f_from);
示例3: show
/**
* @return void
*/
public function show()
{
if (!TwitterAuth::isLogged()) {
?>
Sólo los administradores pueden ver esta página.
<a href="<?=HTMLResponse::getRoute()?>?authenticate=1">
Inicia sesión.
</a><br>
<?
return;
}
else if (!Team::isAdmin()) {
?>
Sólo los administradores pueden ver esta página.<br>
<?
return;
}
else {
$title = trim(HTMLResponse::fromPOST('title', ''));
$description = trim(HTMLResponse::fromPOST('description', ''));
$options = [];
for ($i=1; $i<6; $i++) {
$value = trim(HTMLResponse::fromPOST('option'.$i, ''));
if (strlen($value)) {
$options[] = $value;
}
}
if (strlen($title) && count($options)>=2) {
$poll = Poll::create();
$poll->title = $title;
$poll->description = $description;
$poll->isvisible = true;
$poll->isopen = true;
$poll->username = TwitterAuth::getUserName();
$poll->userid = TwitterAuth::getUserId();
$poll->dateline = time();
$poll->avatar = TwitterAuth::getAvatar();
$poll->save();
foreach($options as $index => $option) {
$pollOption = PollOption::create();
$pollOption->pollid = $poll->pollid;
$pollOption->userid = TwitterAuth::getUserId();
$pollOption->username = TwitterAuth::getUserName();
$pollOption->title = $option;
$pollOption->save();
}
HTMLResponse::exitWithRoute("/votaciones/{$poll->pollid}/");
}
?>
<form action="<?=HTMLResponse::getRoute()?>" method="post">
<div style="padding:3px">
<div class="inblock middle" style="width:120px">
Título
</div>
<input name="title" value="<?=htmlentities($title)?>">
</div>
<div style="padding:3px">
<div class="inblock middle" style="width:120px">
Descripción
</div>
<input name="description" value="<?=htmlentities($description)?>">
</div>
<?
for ($i=1; $i<=6; $i++) {
?>
<div style="padding:3px">
<div class="inblock middle" style="width:120px">
Opción <?=$i?>
</div>
<input name="option<?=$i?>" value="<?=htmlentities($options[$i-1])?>">
</div>
<?
}
?>
<div style="padding:3px">
<div class="inblock middle" style="width:120px">
</div>
<input type="submit" value="Crear votación">
</div>
</form>
<?
}
}
示例4: newPoll
public function newPoll()
{
$title = Input::get('title');
$already_created = Poll::where('title', 'like', '%' . $title . '%');
if (!($already_created->count() > 0)) {
if (isset($title)) {
$poll = Poll::create(array('title' => $title, 'created_by' => Auth::user()->id));
$poll->save();
return null;
}
} else {
return Response::json(array('title' => $already_created->first()->title));
}
//return Response::json($return);
}
示例5: makeAction
public function makeAction()
{
$gender = array(1, 2);
$age = array(1, 2, 3, 4, 5, 6);
$modern = array(1, 2);
$authors = array('local', 'abroad');
$genre = array('drama', 'tradegy', 'comedy', 'detective', 'adventures', 'fy', 'fantasy', 'horror', 'cyber', 'ero', 'bio');
$method = array('pc', 'tablet', 'mobile', 'ebook', 'book');
for ($i = 0; $i < 5000; $i++) {
$poll = new Poll();
$poll->gender = $this->rnd($gender);
$poll->age = $this->rnd($age);
$poll->read_modern = $this->rnd($modern);
$poll->authors = $this->rnd($authors, true);
$poll->genre = $this->rnd($genre, true);
$poll->method = $this->rnd($method, true);
$poll->hash = md5(time() . rand());
$poll->timestamp = time();
$poll->create();
//echo '<br>---<br>';
}
}