本文整理汇总了PHP中Course::errors方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::errors方法的具体用法?PHP Course::errors怎么用?PHP Course::errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course::errors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sandbox
public static function sandbox()
{
// Testaa koodiasi täällä
$course = new Course(array('name' => '', 'city' => ''));
$errors = $course->errors();
Kint::dump($errors);
$hole = new Hole(array('hole_num' => 'yksi', 'par' => 'kolme'));
$errors = $hole->errors();
Kint::dump($errors);
echo Course::next_courseid();
}
示例2: update
public static function update($courseid)
{
$params = $_POST;
$params['courseid'] = $courseid;
$course_params = array('courseid' => $courseid, 'name' => $params['name'], 'city' => $params['city']);
$course = new Course($course_params);
$errors = $course->errors();
// Check hole validity before saving anything
$holes = Hole::course_holes($courseid);
foreach ($holes as $hole) {
$hole->par = $params['hole' . $hole->hole_num];
$errors = array_merge($errors, $hole->errors());
}
if (count($errors) == 0) {
// Course and holes were all valid
$course->update();
foreach ($holes as $hole) {
$hole->update();
}
Redirect::to('/course/' . $courseid, array('message' => 'Rata ja sen väylät päivitetty.'));
} else {
View::make('course/edit.html', array('errors' => $errors, 'attributes' => $params, 'hole_count' => $params['hole_count']));
}
}
示例3: update
/**
* Attempts to update edited course information and displays the edited course.
*
* @param int $id Id of course to be updated.
*/
public static function update($id)
{
$player = self::get_user_logged_in();
if (!$player) {
View::make('player/login.html', array('error' => 'Vain kirjautuneet käyttäjät voivat muokata ratoja.'));
}
$params = $_POST;
$params['url'] = self::fix_url($params['url']);
$params['mapLink'] = self::fix_url($params['mapLink']);
$attributes = array('name' => $params['name'], 'description' => $params['description'], 'address' => $params['address'], 'mapLink' => $params['mapLink'], 'url' => $params['url'], 'id' => $id);
$course = new Course($attributes);
$errors = $course->errors();
if (count($errors) == 0) {
$course->update();
for ($i = 1; $i <= Hole::count_holes($course->id); $i++) {
$hole = Hole::find_by_course_and_holenumber($course->id, $i);
$hole->name = $params[$i . '_name'];
$hole->par = $params[$i . '_par'];
$hole->update();
}
Redirect::to('/course/' . $course->id, array('message' => 'Radan tietoja muutettu.'));
} else {
View::make('course/edit.html', array('errors' => $errors, 'attributes' => $attributes));
}
}