本文整理汇总了PHP中Entry::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Entry::save方法的具体用法?PHP Entry::save怎么用?PHP Entry::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Creates a new entry, puts the id into the session and
* redirects back to the index page.
*/
public function store()
{
if (Entry::canCreateOrEdit() === false) {
return Redirect::route('entry.index')->withMessage("Sorry, the competition has now started and new entries cannot be created.");
}
$input = Input::all();
$validator = Validator::make($input, Entry::$entry_rules);
if ($validator->fails()) {
return Redirect::route('entry.create')->withInput()->withErrors($validator);
}
DB::beginTransaction();
$entry = new Entry();
$entry->email = $input['email'];
$entry->secret = Hash::make($input['secret']);
$entry->confirmation = uniqid('', true);
$entry->first_name = $input['first_name'];
$entry->last_name = $input['last_name'];
$entry->peer_group = $input['peer_group'];
$entry->save();
$matches = Match::all();
foreach ($matches as $match) {
$match_prediction = new MatchPrediction();
$match_prediction->team_a = $match->team_a;
$match_prediction->team_b = $match->team_b;
$match_prediction->pool = $match->pool;
$match_prediction->match_date = $match->match_date;
$entry->matchPredictions()->save($match_prediction);
}
DB::commit();
$this->sendConfirmationEmail($entry);
$this->putEntryIdIntoSession($entry->id);
return View::make('entry.edit')->with('entry', $entry);
}
示例2: save
public static function save($entry_id, $type, $user_id, $privacy)
{
$entry = new Entry();
$entry->entry_id = $entry_id;
$entry->type = $type;
$entry->user_id = $user_id;
$entry->privacy = $privacy;
$entry->save();
return $entry;
}
示例3: postAdd
public function postAdd($p, $z)
{
// update Zoop::Form so that it it can handle consolidating the edit and view pages here
$entry = new Entry();
$entry->start = $_POST['start'];
$entry->end = $_POST['end'];
$entry->title = $_POST['title'];
$entry->is_duration = isset($_POST['is_duration']) && $_POST['is_duration'] ? 1 : 0;
$entry->save();
$this->redirect('');
}
示例4: importEntry
public static function importEntry($path)
{
$parts = explode('/', $path);
$info = explode('_', $parts[count($parts) - 2]);
// do the database part
$entry = new Entry((int) $info[0]);
$entry->name = $info[1];
$entry->assignHeaders();
$entry->save();
// do the file system part
$entry->cacheContent();
}
示例5: importEntry
public static function importEntry($path)
{
$info = self::parsePath($path);
// do the database part
$entry = new Entry((int) $info['id']);
$entry->name = $info['name'];
$entry->simple = $info['simple'];
$entry->assignHeaders();
$entry->save();
// do the file system part
$entry->cacheContent();
}
示例6: importEntry
public static function importEntry($path)
{
$parts = explode('/', $path);
$dir = $parts[count($parts) - 2];
$id = (int) substr($dir, 0, strpos($dir, '_'));
$name = substr($dir, strpos($dir, '_') + 1);
// do the database part
$entry = new Entry($id);
$entry->name = $name;
$entry->assignHeaders();
$entry->save();
// do the file system part
$entry->cacheContent();
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store($logbook_id)
{
$logbook = Logbook::findOrFail($logbook_id);
if ($logbook->user_id == Auth::user()->id or $logbook->user_id == 0) {
$entry = new Entry(Input::only('title', 'body', 'started_at', 'finished_at', 'evidence_id', 'who', 'what', 'where', 'which', 'way', 'when', 'why'));
$entry->logbook_id = $logbook->id;
if ($entry->validate()) {
$entry->save();
} else {
return View::make('entries.create', ['entry' => $entry, 'logbook' => $logbook])->withErrors($entry->validator());
}
return Redirect::to(route('logbooks.show', [$logbook->id]))->with('message', ['content' => 'Entry met succes aangemaakt!', 'class' => 'success']);
} else {
return Redirect::to(route('logbooks.show', [$logbook->id]))->with('message', ['content' => 'Geen rechten om entry weg te schrijven!', 'class' => 'danger']);
}
}
示例8: actionCreate
/**
* @return void
*/
public function actionCreate()
{
// create form
$model = new Entry('create');
// form is submitted
if (isset($_POST['Entry'])) {
$model->attributes = $_POST['Entry'];
// save model & redirect to index
if ($model->save()) {
$model->resaveTags();
// set flash
Yii::app()->user->setFlash('success', 'The entry was created successfully.');
// redirect to index
$this->redirect(array('index'));
}
}
$this->render('create', array('model' => $model));
}
示例9: doPOST
public function doPOST()
{
require_once DB_PATH . '/core/lib/entry.php';
$id = intval($this->request->entry);
try {
$entry = new Entry($this->db, $id);
if (!($this->auth->authenticated() && $entry->get('user') == $_SESSION['auth_id'])) {
$entry->check_pass($_POST['password']);
}
$entry->update_tags($_POST['tags']);
$entry->update('title', $_POST['title']);
$entry->update('safe', intval($_POST['rating']));
$entry->save();
redirect('view', $id);
} catch (Exception $e) {
die($e->GetMessage());
redirect('edit', $id);
}
}
示例10: store
/**
* Store a newly created resource in storage.
* POST /entries
*
* @return Response
*/
public function store()
{
// Validate input.
$input = array('food' => Input::get('food'), 'servings' => Input::get('servings'));
$rules = array('food' => 'required', 'servings' => array('required', 'numeric'));
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
$messages = $validator->messages();
return Redirect::back()->withErrors($messages)->withInput();
}
// Store the input in an entry.
$entry = new Entry();
$entry->food_id = Input::get('food');
$entry->user_id = Auth::user()->id;
$entry->servings = Input::get('servings');
if ($entry->save()) {
return Redirect::route('entries.index');
} else {
return Redirect::back()->withInput();
}
}
示例11: updateEntry
function updateEntry($id)
{
if (is_null($id)) {
Functions::setResponse(400);
}
$data = Functions::getJSONData();
try {
$c = new Entry($id);
foreach ($c->getFields() as $field) {
$value = Functions::elt($data, $field['name']);
if (is_null($value)) {
Functions::setResponse(400);
}
$c->set($field['name'], $value);
}
$c->set('id', $id);
$c->save();
return true;
} catch (RuntimeException $e) {
Functions::setResponse(404);
}
}
示例12: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Entry();
if (isset($_POST['amount']) && isset($_POST['invoice']) && isset($_POST['name'])) {
$inventory_info = $_POST["name"];
$inventory_info_arr = explode(":", $inventory_info);
$inventory_id = intval($inventory_info_arr[0]);
$inventory = Inventory::model()->findByPk($inventory_id);
if ($inventory->id) {
$inventory_id = $inventory->id;
$model->inventory = $inventory_id;
$model->item = $inventory->name . " - " . $inventory->model;
$model->price = intval($_POST['price']);
$model->amount = intval($_POST['amount']);
$model->invoice = intval($_POST['invoice']);
if ($model->save()) {
$this->redirect(array('/invoice/view', 'id' => $model->invoice));
}
} else {
throw new Exception("Invalid Inventory ID");
}
}
$this->render('/invoice/view', array('id' => $_POST['invoice']));
}
示例13: actionEntry
public function actionEntry()
{
//关闭页面布局
$this->layout = false;
//创建表单模型
$entry = new Entry();
//如果是Post请求提交
if (Yii::$app->request->getIsPost()) {
//表单模型设置属性为post值
$entry->setAttributes(Yii::$app->request->post());
//表单模型数据验证
if ($entry->validate()) {
//正确即保存数据
$result = $entry->save();
//返回保存后的信息
if ($result) {
var_dump($entry->attributes);
} else {
var_dump($entry->getErrors());
}
} else {
//返回错误提示
var_dump($entry->getErrors());
}
} else {
//如果不是Post请求,正常显示模板
return $this->render('entry', ['model' => $entry]);
}
}
示例14: login
//.........这里部分代码省略.........
throw new Exception(__('Section does not contain required fields.'));
}
// Simulate data from cookie:
if (empty($data) and $this->readSession()) {
$session = $this->readSession();
$fields = array($field_email->{'element-name'} => $session->email, $field_password->{'element-name'} => $session->login);
} else {
$this->deleteSession();
$fields = $data['fields'];
}
// Apply default values:
foreach ($this->parameters()->{'defaults'} as $name => $value) {
if (!isset($fields[$name])) {
$fields[$name] = $value;
} else {
if (is_string($fields[$name]) and $fields[$name] == '') {
$fields[$name] = $value;
} else {
if (is_array($fields[$name]) and empty($fields[$name])) {
$fields[$name] = array($value);
}
}
}
}
// Apply override values:
foreach ($this->parameters()->{'overrides'} as $name => $value) {
if (is_array($fields[$name])) {
$fields[$name] = array($value);
} else {
$fields[$name] = $value;
}
}
// Find values:
if (isset($field_name)) {
$value_name = (isset($fields[$handle_name]) and strlen($fields[$handle_name]) > 0) ? $fields[$handle_name] : null;
}
if (isset($field_email)) {
$value_email = (isset($fields[$handle_email]) and strlen($fields[$handle_email]) > 0) ? $fields[$handle_email] : null;
}
if (isset($field_password)) {
$value_password = (isset($fields[$handle_password]) and strlen($fields[$handle_password]) > 0) ? $fields[$handle_password] : null;
}
if (is_null($value_email) and is_null($value_name) or is_null($value_password)) {
throw new Exception(__('Missing login credentials.'));
}
// Build query:
$where_password = array();
$value_password = array('value' => $value_password, 'type' => 'is');
$field_password->buildFilterQuery($value_password, $joins, $where_password, $parameter_output);
if (isset($field_email) and !is_null($value_email)) {
$where_email = $where_password;
$value_email = array('value' => $value_email, 'type' => 'is');
$field_email->buildFilterQuery($value_email, $joins, $where_email, $parameter_output);
$wheres[] = '(' . implode("\nAND ", $where_email) . ')';
}
if (isset($field_name) and !is_null($value_name)) {
$where_name = $where_password;
$value_name = array('value' => $value_name, 'type' => 'is');
$field_name->buildFilterQuery($value_name, $joins, $where_name, $parameter_output);
$wheres[] = '(' . implode("\nAND ", $where_name) . ')';
}
array_unshift($wheres, null);
$wheres = implode("\nOR ", $wheres);
$query = "\nSELECT DISTINCT\n\te.*\nFROM\n\t`tbl_entries` AS e{$joins}\nWHERE\n\tFALSE{$wheres}\n\t\t\t";
//echo '<pre>', htmlentities($query), '</pre>'; exit;
// Find entry:
$result = Symphony::Database()->query($query, array(), 'EntryResult');
if (!$result->valid()) {
throw new Exception(__('Invalid login credentials.'));
}
$entry = $result->current();
$email = $entry->data()->{$handle_email}->value;
$code = $entry->data()->{$handle_password}->code;
$login = $this->driver->createToken($code, 'login');
if ($this->parameters()->{'create-cookie'} == true) {
$this->writeCookie($login, $email);
}
$event_name = $this->parameters()->{'root-element'};
$parameter_output->{"event-{$event_name}.system.id"} = $entry->id;
$parameter_output->{"event-{$event_name}.member.email"} = $email;
$parameter_output->{"event-{$event_name}.member.login"} = $login;
// Remove login fields:
unset($fields[$handle_name], $fields[$handle_email], $fields[$handle_password]);
// Set password as optional:
$fields[$handle_password] = array('validate' => array('optional' => $this->driver->createToken($code, 'validate')), 'change' => array('optional' => $this->driver->createToken($code, 'change')));
// Update fields:
$entry->setFieldDataFromFormArray($fields);
###
# Delegate: EntryPreCreate
# Description: Just prior to creation of an Entry. Entry object provided
Extension::notify('EntryPreCreate', '/frontend/', array('entry' => &$entry));
$status = Entry::save($entry, $errors);
if ($status != Entry::STATUS_OK) {
throw new Exception(__('Entry encountered errors when saving.'));
}
###
# Delegate: EntryPostCreate
# Description: Creation of an Entry. New Entry object is provided.
Extension::notify('EntryPostCreate', '/frontend/', array('entry' => $entry));
}
示例15: cat_reset
public function cat_reset()
{
// This is a big one. Reset all the categories balances to 0 and does it in an
// entry style, so it can be reversed.
try {
DB::transaction(function () {
// first we save the monthly resetentry
$e = new Entry();
$e->uid = $this->user->uid;
$e->paid_to = 0;
$e->purchase_date = date('Y-m-d');
$e->total_amount = 0;
$e->description = 'Monthly Reset for ' . date('M Y');
$e->type = 100;
$e->save();
foreach ($this->user->user_categories as $uc) {
$tmp = [];
if (in_array($uc->class, [20, 30])) {
$this->save_entry_section($uc->ucid, $e->entid, 2, $uc->balance);
if ($uc->class == 20) {
// we need to see if we need to alter overflow amt
if ($uc->balance < $uc->top_limit) {
$uc->saved += $uc->top_limit - $uc->balance;
} else {
// means spent more than what we budgeted for, we need to reduce the saved if there is some
if ($uc->saved > 0) {
if ($uc->balance - $uc->top_limit > $uc->saved) {
$uc->saved = 0.0;
} else {
$uc->saved = $uc->saved - ($uc->balance - $uc->top_limit);
}
}
}
$tmp = ['balance' => 0.0, 'saved' => $uc->saved];
} else {
// set balance to 0 and save uc
$tmp['balance'] = 0.0;
}
DB::table('user_categories')->where('ucid', $uc->ucid)->update($tmp);
}
}
});
} catch (Exception $e) {
//dd($e->getMessage());
return Response::json(array('status' => false, 'errors' => array('total' => 'There was a problem with the categories reset.')), 400);
}
return Response::json(array('success' => true), 200);
}