本文整理匯總了PHP中Guardian::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Guardian::save方法的具體用法?PHP Guardian::save怎麽用?PHP Guardian::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Guardian
的用法示例。
在下文中一共展示了Guardian::save方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addGuardian
/**
* @before _secure, _school
*/
public function addGuardian($scholar_user_id)
{
$usr = \User::first(array("id = ?" => $scholar_user_id), array("id"));
if (!$usr) {
self::redirect("/school");
}
$this->setSEO(array("title" => "Parent Info | Student | School"));
$view = $this->getActionView();
if (RequestMethods::post("action") == "saveParent") {
$opts = array();
$opts["name"] = RequestMethods::post("name");
$opts["email"] = RequestMethods::post("email");
$opts["phone"] = RequestMethods::post("phone");
try {
$user = $this->_createUser($opts);
$loc = new Location(array("address" => RequestMethods::post("address"), "city" => RequestMethods::post("city"), "latitude" => "", "longitude" => "", "user_id" => $user->id));
$loc->save();
$guardian = new Guardian(array("user_id" => $user->id, "scholar_user_id" => $scholar_user_id, "relation" => RequestMethods::post("relation"), "occupation" => RequestMethods::post("occupation"), "qualification" => RequestMethods::post("qualification"), "location_id" => $loc->id));
$guardian->save();
$view->set("success", $guardian->relation . " info saved successfully!!");
} catch (\Exception $e) {
$view->set("error", true);
$view->set("message", $e->getMessage());
}
}
}