本文整理匯總了PHP中Participant::ins方法的典型用法代碼示例。如果您正苦於以下問題:PHP Participant::ins方法的具體用法?PHP Participant::ins怎麽用?PHP Participant::ins使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Participant
的用法示例。
在下文中一共展示了Participant::ins方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: savepart
public function savepart()
{
try {
if (Check::digits($_POST['study_id'], $empty = false)) {
$study_id = $_POST['study_id'];
} else {
throw new Exception("bad study id!");
}
if (Check::digits($_POST['participant_id'])) {
$part_id = $_POST['participant_id'];
} else {
throw new Exception("bad participant id!");
}
if (!Check::isemail($_POST['email'])) {
throw new Exception("need a valid email!");
}
if (empty($_POST['firstname'])) {
throw new Exception("need a first name!");
}
unset($_POST['participant_id']);
unset($_POST['study_id']);
$p = new Participant();
if ($part_id) {
if ($p->upd($part_id, $_POST) === false) {
throw new Exception($p->err());
}
} else {
if ($p->ins($_POST) === false) {
throw new Exception($p->err());
}
$part_id = $p->getid();
$e = new Enrollment();
if ($e->ins(array('study_id' => $study_id, 'participant_id' => $part_id, 'enrolled' => date('Y-m-d H:i:s'))) === false) {
throw new Exception($e->err());
}
}
View::assign('study_id', $study_id);
View::assign('part_id', $part_id);
return 'participant.tpl';
} catch (Exception $e) {
$this->err($e);
View::assign('error', $this->error);
return 'error.tpl';
}
}