本文整理汇总了PHP中Participant::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Participant::update方法的具体用法?PHP Participant::update怎么用?PHP Participant::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Participant
的用法示例。
在下文中一共展示了Participant::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public static function update($id)
{
self::check_admin_logged_in();
$attributes = self::get_attributes();
$attributes['id'] = $id;
$attributes['competition_name'] = Competition::find($attributes['competition_id'])->name;
$attributes['competitor_name'] = Competitor::find($attributes['competitor_id'])->name;
$attributes['standing'] = Participant::find($id)->standing;
$participant = new Participant($attributes);
$errors = $participant->validate_number();
if (count($errors) == 0) {
$participant->update();
Redirect::to('/competition/' . $participant->competition_id . '/participants', array('message' => 'Kilpailijan numeroa muokattu onnistuneesti!'));
} else {
self::edit_view(array(Competition::find($participant->competition_id)), array(Competitor::find($participant->competitor_id)), $attributes, $errors);
}
}
示例2: applySettingsToParticipants
private function applySettingsToParticipants()
{
//only checked attributes are processed
//returns FALSE if no attribute and/or no participant is checked
//works only for single-Select-Inputs!
//checked value = COL_NAME
//form control name = COL_NAME
//form control value = CELL_VALUE
$partAttrs = $this->getRequest()->getParam('participantAttributeChecked');
if ($partAttrs == NULL) {
//no attribute checked
return FALSE;
}
$data = array();
foreach ($partAttrs as $attr => $attrName) {
$attrValue = $this->getRequest()->getParam($attrName);
//boolean: write 1 instead of "on" to database
if ($attrName == Participant::COL_STOCK_ASSESSMENT && $attrValue == "on") {
$attrValue = 1;
}
$data = $data + array($attrName => $attrValue);
}
//echo $data;
$partIds = $this->getRequest()->getParam(Participant::COL_ID);
if ($partIds == NULL) {
//no participant checked
return FALSE;
}
$part = new Participant();
foreach ($partIds as $partId) {
$where = $part->getAdapter()->quoteInto(Participant::COL_ID . ' = ?', $partId);
$part->update($data, $where);
}
$this->redirectTo('index');
return TRUE;
}