本文整理汇总了PHP中Pack::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Pack::all方法的具体用法?PHP Pack::all怎么用?PHP Pack::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pack
的用法示例。
在下文中一共展示了Pack::all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
public function submit($song_id = null)
{
$this->require_login();
if (!$song_id) {
$this->content_view = "scores/submit";
$this->data['songs'] = Ranked_file::get_all_charts();
$this->data['packs'] = Pack::all(array('order' => 'name asc'));
} else {
if (Ranked_file::count(array('conditions' => array('id = ?', $song_id))) != 1) {
redirect('scores/submit');
} else {
if ($_POST) {
$song = Ranked_file::find($song_id);
$this->data['song'] = $song;
$total_notes = $this->input->post('marvelous_count') + $this->input->post('perfect_count') + $this->input->post('great_count') + $this->input->post('good_count') + $this->input->post('boo_count') + $this->input->post('miss_count');
$total_holds = $this->input->post('ok_count');
if ($total_notes > $song->taps || $total_holds > $song->holds) {
$this->content_view = "scores/confirm";
$this->data['error_nc'] = true;
} elseif ($this->form_validation->run('submit_score') == FALSE) {
$this->content_view = "scores/confirm";
$this->data['error'] = true;
} else {
$attributes = array('user_id' => $this->session->userdata('user_id'), 'file_id' => $song_id, 'date_achieved' => $this->input->post('score_achieved'), 'marvelous_count' => $this->input->post('marvelous_count'), 'perfect_count' => $this->input->post('perfect_count'), 'great_count' => $this->input->post('great_count'), 'good_count' => $this->input->post('good_count'), 'boo_count' => $this->input->post('boo_count'), 'miss_count' => $this->input->post('miss_count'), 'ok_count' => $this->input->post('ok_count'), 'mines_hit' => $this->input->post('mines_hit'), 'screenshot_url' => $this->input->post('screenshot_url'));
$new_score = new User_score($attributes);
$new_score->save();
// Check if score is below AA
$max_dp_max = $song->dance_points;
$max_dp_achieved = $new_score->marvelous_count * 2 + $new_score->perfect_count * 2 + $new_score->great_count * 1 + $new_score->boo_count * -4 + $new_score->miss_count * -8 + $new_score->ok_count * 6 + $new_score->mines_hit * -8;
$max_dp_percent = $max_dp_achieved / $max_dp_max * 100;
if ($max_dp_percent < 93) {
$new_score->status = "below_aa";
$new_score->save();
}
// Check if score is in top 10% of all scores
$this->data['score_pending'] = false;
$percentile = User_score::get_top_10_percentile();
if ($song->difficulty_score > $percentile) {
$new_score->status = "pending";
$new_score->was_pending = 1;
$new_score->save();
$this->data['score_pending'] = true;
}
$this->content_view = "scores/success";
}
} else {
$this->data['song'] = Ranked_file::find($song_id);
$this->content_view = "scores/confirm";
$this->data['error'] = false;
}
}
}
}
示例2: get_recent_packs
public static function get_recent_packs()
{
return Pack::all(array("select" => "`packs`.*, (SELECT COUNT(*) FROM `ranked_files` WHERE `ranked_files`.`pack_id` = `packs`.`id`) AS file_count, (SELECT AVG(difficulty_score) FROM `ranked_files` WHERE `ranked_files`.`pack_id` = `packs`.`id` AND `ranked_files`.`rate` = 1) as average", 'order' => '`packs`.id DESC', 'limit' => 10));
}
示例3: edit_chart
function edit_chart($id)
{
$this->data['subtitle'] = "Edit Ranked Chart";
$this->data['chart'] = Ranked_file::find($id);
if (intval($this->input->post('step')) == 2) {
if ($this->form_validation->run('rank_chart') == FALSE) {
$this->data['packs'] = Pack::all(array('order' => 'name asc'));
$this->data['error'] = true;
$this->content_view = "mod/edit_chart";
} else {
// Validation good, save the file!
$this->data['chart']->pack_id = $this->input->post('pack_id');
$this->data['chart']->stamina_file = $this->input->post('stamina_file');
$this->data['chart']->file_type = $this->input->post('file_type');
$this->data['chart']->date_ranked = $this->input->post('date_ranked');
$this->data['chart']->rate = $this->input->post('rate');
$this->data['chart']->title = $this->input->post('title');
$this->data['chart']->subtitle = $this->input->post('subtitle');
$this->data['chart']->artist = $this->input->post('artist');
$this->data['chart']->length = $this->input->post('length');
$this->data['chart']->dance_points = $this->input->post('dance_points');
$this->data['chart']->notes = $this->input->post('notes');
$this->data['chart']->taps = $this->input->post('taps');
$this->data['chart']->jumps = $this->input->post('jumps');
$this->data['chart']->hands = $this->input->post('hands');
$this->data['chart']->quads = $this->input->post('quads');
$this->data['chart']->holds = $this->input->post('holds');
$this->data['chart']->mines = $this->input->post('mines');
$this->data['chart']->peak_nps = $this->input->post('peak_nps');
$this->data['chart']->avg_nps = $this->input->post('avg_nps');
$this->data['chart']->avg_weighted_nps = $this->input->post('avg_weighted_nps');
$this->data['chart']->difficulty_score = $this->input->post('difficulty_score');
$this->data['chart']->raw_file = $this->input->post('raw_file');
$this->data['chart']->save();
$rate = $this->input->post('rate');
$log_string = $this->session->userdata('username') . " (" . $this->session->userdata('display_name') . ") edited ranked chart: " . $this->input->post('title') . " " . number_format($rate, 1) . "x " . " - " . $this->input->post('difficulty_score');
write_to_mod_log($log_string);
$this->data['rank_success'] = true;
$this->content_view = "mod/edit_chart";
}
} else {
$this->data['packs'] = Pack::all(array('order' => 'name asc'));
$this->content_view = "mod/edit_chart";
}
}