本文整理匯總了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;
}