本文整理匯總了PHP中DAO::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP DAO::save方法的具體用法?PHP DAO::save怎麽用?PHP DAO::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DAO
的用法示例。
在下文中一共展示了DAO::save方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveNew
protected function saveNew($user)
{
@($dao = new DAO(User));
$accessLevel = $user->get("usr_accessLevel");
if (!isset($accessLevel)) {
$user->set("usr_accessLevel", 1);
} else {
if ($accessLevel > 1) {
if (UserSession::getInstance()->isLogged() !== true) {
die("<h1>Die f****** cracker!</h1>");
} else {
if (UserSession::getInstance()->getAccessLevel() < $accessLevel) {
die("<h1>Die f****** cracker!</h1>");
}
}
}
}
$user->set("usr_deleted", 0);
$user->set('usr_confirmationCode', sha1($user->get('usr_id') . $user->get('usr_email') . $user->get('usr_accessLevel')));
$status = $dao->save($user);
if ($status !== true) {
die("Um erro ocorreu ao tentar cadastrar o usuário, favor contatar um professor:<br />" . $status);
}
return true;
}
示例2: saveNew
protected function saveNew($model)
{
@($dao = new DAO(Discipline));
$model->set('dsc_deleted', 0);
$status = $dao->save($model);
if ($status !== true) {
die("Um erro ocorreu ao tentar cadastrar o usuário, favor contatar um professor:<br />" . $status);
}
return true;
}
示例3: save
public function save()
{
if (UserSession::getInstance()->getAccessLevel() < 3) {
die("<h1>Forbidden resource for you.</h1>");
}
$model = new TestProblems();
$model->setFields($this->params);
$model->set("tpb_deleted", 0);
@($dao = new DAO(TestProblems));
$qbuilder = new QueryBuilder('testproblems');
$qbuilder->addEqual('tpb_tst_id', $model->get('tpb_tst_id'));
$qbuilder->addEqual('tpb_prb_id', $model->get('tpb_prb_id'));
$existent = $dao->findByQuery($qbuilder);
if (count($existent) < 1) {
$status = $dao->save($model);
} else {
$status = $dao->update($model);
}
if ($status !== true) {
die("Um erro ocorreu ao tentar cadastrar o usuário, favor contatar um professor:<br />" . $status);
}
return true;
}
示例4: logAction
public function logAction($user, $test, $msg, $hostname = 'N/A', $question = 'N/A', $score = 'N/A')
{
if ($hostname == 'N/A' && isset($_SERVER['REMOTE_HOST'])) {
$hostname = $_SERVER['REMOTE_HOST'];
}
@($dao = new DAO(TestLog));
$model = new TestLog();
$today = new DateTime('now');
$model->set("tsl_time", $today->format(Model::$SQL_DATE_FORMAT));
$model->set("tsl_usr_id", $user);
$model->set("tsl_tst_id", $test);
$model->set("tsl_message", $msg);
$model->set("tsl_hostname", $hostname);
$model->set("tsl_remoteAddr", $_SERVER['REMOTE_ADDR']);
$model->set("tsl_questNumber", $question);
$model->set("tsl_score", $score);
$status = $dao->save($model);
if ($status !== true) {
die("Um erro ocorreu ao tentar salvar log, favor contatar um professor:<br />" . $status);
}
}
示例5: saveIfNotExists
protected function saveIfNotExists($model)
{
if (!isset($model)) {
return false;
}
$retrieved = $this->retrieve($model);
if (isset($retrieved)) {
return true;
}
@($dao = new DAO(TestTrial));
$today = new DateTime('now');
$model->set('ttl_lastTrial', $today->format(Model::$SQL_DATE_FORMAT));
$model->set("ttl_deleted", 0);
$model->set("ttl_remoteAddr", $_SERVER['REMOTE_ADDR']);
$model->set("ttl_hostname", "N/A");
$model->set("ttl_reason", "<i>Nenhuma tentativa realizada ainda.</i>");
$status = $dao->save($model);
if ($status !== true) {
die("Um erro ocorreu ao tentar iniciar prova, favor contatar um professor:<br />" . $status);
}
return true;
}