本文整理汇总了PHP中Task::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::save方法的具体用法?PHP Task::save怎么用?PHP Task::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
function get($criteria = null, $order = null)
{
$sql = "SELECT tasks.*, CONCAT(users.first_name, ' ', users.last_name) AS assigned_to_name\n FROM tasks\n LEFT JOIN users ON users.id = tasks.assigned_to";
if (isset($criteria) && is_numeric($criteria)) {
$sql .= " WHERE tasks.id = {$criteria}";
$task = parent::get_one($sql);
$this->update_status();
return $task;
} else {
$sql = $this->add_criteria($sql, $criteria);
$sql = $this->modify_sql_for_user_type($sql);
$sql = $this->add_order_by($sql, $order);
$tasks = parent::get($sql);
foreach ($tasks as &$task) {
//create the invoice
$task_object = new Task($task);
//todo: i don't think this makes any sense because the invoice status will already be updated when I create the invoice using new Invoice
//store the current task status as it exists in the database
$old_status = $task_object->status_text;
//update the task status
$task_object->update_status();
//if the old status and the new status do not match, then we need to save this task back to the database.
if ($old_status != (string) $task_object->status_text) {
//todo:make sure this isn't saving each time
$task_object->save(false);
}
//we need to add the status text back the task array, since we're sending the array to the client,
//not the object
$task['status_text'] = $task_object->status_text;
}
return $tasks;
}
}
示例2: after
public function after()
{
echo "after\n";
$insert = 0;
// 判断是否插入表
$class_name = get_class($this);
$type = str_replace('Event', '', $class_name);
$task = new Task();
if ($this->event_rs['err_no'] > 0) {
// 代表错误
$task->is_success = 0;
$this->event_rs['class'] = $this->class;
$this->event_rs['param'] = $this->param;
if ($this->retry_cnt >= 3) {
$insert = 1;
}
} else {
$task->is_success = 1;
$insert = 1;
}
// 成功则入库 第一次失败则不入库 第三次失败才一起入库
$task->create_time = time();
$task->retry_cnt = $this->retry_cnt;
$task->event = $type;
$task->param = json_encode($this->param);
if ($insert > 0) {
$task->save();
}
$this->event_rs['retry_cnt'] = $this->retry_cnt;
}
示例3: store
/**
* Store a newly created resource in storage.
* POST /task
*
* @return Response
*/
public function store()
{
// Input::merge(array_map('trim', Input::all()));
$input = Input::all();
$validation = Validator::make($input, Task::$rules);
if ($validation->passes()) {
$task = new Task();
$task->task = strtoupper(Input::get('task'));
$task->description = strtoupper(Input::get('description'));
$task->save();
$id = $task->id;
$gettime = time() - 14400;
$datetime_now = date("H:i:s", $gettime);
$task_approver = Input::get('task_approver');
$task_receiver = Input::get('task_receiver');
foreach ($task_approver as $row_approver) {
DB::table('task_approver')->insert(array(['task_id' => $id, 'user_id' => $row_approver, 'datetime_created' => date('Y-m-d') . $datetime_now]));
}
foreach ($task_receiver as $row_receiver) {
DB::table('task_receiver')->insert(array(['task_id' => $id, 'user_id' => $row_receiver, 'datetime_created' => date('Y-m-d') . $datetime_now]));
}
return Redirect::route('task.index')->with('class', 'success')->with('message', 'Record successfully created.');
} else {
return Redirect::route('task.create')->withInput()->withErrors($validation)->with('class', 'error')->with('message', 'There were validation error.');
}
}
示例4: actionCreate
public function actionCreate()
{
switch ($_GET['model']) {
case 'user':
$model = new User('create');
break;
case 'task':
$model = new Task();
break;
default:
$this->_sendResponse(501, Yii::t('tasklist', 'Mode "create" is not implemented for model "{model}"', array('{model}' => $_GET['model'])));
exit;
}
foreach ($_POST as $var => $value) {
if ($model->hasAttribute($var)) {
$model->{$var} = $value;
} else {
$this->_sendResponse(500, Yii::t('tasklist', 'Parameter "{param}" is not allowed', array('{param}' => $var)));
}
}
if ($model->save()) {
$this->_sendResponse(200, CJSON::encode($model->attributes));
} else {
$this->_sendResponse(500, CJSON::encode($model->errors));
}
}
示例5: testKanbanItemSave
public function testKanbanItemSave()
{
$accounts = Account::getByName('anAccount');
$user = UserTestHelper::createBasicUser('Billy');
$task = new Task();
$task->name = 'MyTask';
$task->owner = $user;
$task->requestedByUser = $user;
$task->description = 'my test description';
$taskCheckListItem = new TaskCheckListItem();
$taskCheckListItem->name = 'Test Check List Item';
$task->checkListItems->add($taskCheckListItem);
$task->activityItems->add($accounts[0]);
$task->status = Task::STATUS_IN_PROGRESS;
$this->assertTrue($task->save());
$this->assertEquals(1, KanbanItem::getCount());
$id = $task->id;
unset($task);
$task = Task::getById($id);
//KanbanItem is created after saving Task
$kanbanItems = KanbanItem::getAll();
$this->assertCount(1, $kanbanItems);
$kanbanItem = $kanbanItems[0];
$this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem->type);
}
示例6: store
public static function store()
{
self::check_logged_in();
$params = $_POST;
if (empty($_POST['projects'])) {
$errors[] = 'Select at least one project!';
$projects = '';
} else {
$projects = $_POST['projects'];
}
$attributes = array('description' => $params['description'], 'priority' => $params['priority'], 'status' => 0, 'projectids' => $projects);
$task = new Task($attributes);
//$errors = $task->errors(); // Deprecated: Switched to valitron. Calls all validators
$errors = $task->validateTask();
// Valitron takes care of putting all errors in one array
//Kint::dump($params); // Debug, comment out Redirect if used!
//Kint::dump($task);
if (count($errors) == 0) {
$task->save();
// Tell task-model to save this object to DB
foreach ($projects as $project) {
Project::addTask($task->id, $project);
// We don't know the id before it is saved!
Project::updateCount($project);
}
Redirect::to('/task/' . $task->id, array('message' => 'Task added to database!'));
} else {
Kint::dump($errors);
$projects = Project::all();
Kint::dump($attributes);
Kint::dump($projects);
View::make('task/new.html', array('errors' => $errors, 'attributes' => $attributes, 'projects' => $projects));
}
}
示例7: User
function uncomplete_task()
{
$id = $this->input->post('id');
$user = new User();
$task = new Task();
if ($task->where('user_id', $this->dx_auth->get_user_id())->where('id', $id)->count() == 0) {
return;
}
$task->get_by_id($id);
$task->completed = 0;
$task->save();
$docket = new Docket();
$docket->get_by_id($task->docket_id);
$task->clear();
if ($task->where('docket_id', $docket->id)->where('completed', 0)->count() == 0) {
$docket->completed = 1;
$docket->save();
} else {
$docket->completed = 0;
$docket->save();
}
$gold = $this->treasure->decrease($this->dx_auth->get_user_id());
$task->clear();
$task->get_by_id($id);
$result = array('id' => $task->id, 'name' => $task->name, 'docket_id' => $docket->id, 'due' => $task->due, 'gold' => $gold);
echo json_encode($result);
}
示例8: store
public static function store()
{
parent::check_logged_in();
// POST-pyynnön muuttujat sijaitsevat $_POST nimisessä assosiaatiolistassa
$params = $_POST;
// Alustetaan uusi task-luokan olion käyttäjän syöttämillä arvoilla
/*$task = new task(array(
'name' => $params['name'],
'description' => $params['description'],
'publisher' => $params['publisher'],
'published' => $params['published']
));*/
$params['user_id'] = parent::get_user_logged_in()->id;
$task = new Task($params);
$errors = $task->validate();
if (!$errors) {
// Kutsutaan alustamamme olion save metodia, joka tallentaa olion tietokantaan
$task->save();
// Ohjataan käyttäjä lisäyksen jälkeen pelin esittelysivulle
//Redirect::to('/task/' . $task->id, array('message' => 'Task has been added!'));
Redirect::to('/task', array('message' => 'Task has been added!'));
} else {
View::make('task/new.html', array('errors' => $errors, 'attributes' => $params, 'title' => 'new task'));
}
}
示例9: addTask
public function addTask()
{
if ($_POST) {
// Lets start validation
// validate input
$rules = array('name' => 'required|max:50', 'description' => 'required', 'didyouknow' => 'required', 'reference' => 'required');
$validation = Validator::make(Input::all(), $rules);
if ($validation->fails()) {
Input::flash();
return Redirect::back()->withInput()->withErrors($validation);
}
$task = new Task();
$task->name = Input::get('name');
$task->description = Input::get('description');
$task->didyouknow = Input::get('didyouknow');
$task->reference = Input::get('reference');
$task->author = Input::get('taskauthor');
$task->createdby = 0;
$task->suspended = 0;
$task->number = 0;
$task->save();
return Redirect::to('tasks/manage');
}
return View::make('task.add');
}
示例10: create
/**
* Show the form for creating a new resource.
* GET /tasks/create
*
* @return Response
*/
public function create()
{
// Rules
$rules = array('weight' => 'integer|between:1,5', 'name' => 'required');
// Custom messages
$messages = array('between' => 'The :attribute must be between :min - :max.', 'integer' => ':attribute must be a number');
// Create validation
$validator = Validator::make(Input::all(), $rules, $messages);
// Check validation
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
// Insert the task to database
$task = new Task();
$task->project_id = Input::get('projectId');
$task->user_id = Auth::id();
$task->name = Input::get('name');
$task->weight = Input::get('weight');
if (!Input::get('weight')) {
$task->weight = 1;
}
$task->state = "incomplete";
$task->save();
// Increase the users overall task count
$user = User::find(Auth::id());
$user->tasks_created = $user->tasks_created + 1;
$user->save();
return Redirect::back()->with('success', Input::get('name') . " has been created.");
}
示例11: store
public function store()
{
$task = new Task(Input::all());
if (!$task->save()) {
return Redirect::back()->withInput()->withErrors($task->getErrors());
}
return Redirect::home();
}
示例12: store
/**
* [addPostTask description]
*/
public function store()
{
if (Input::has('task_label')) {
$task = new Task();
$task->label = Input::get('task_label');
$task->save();
}
return Redirect::back();
}
示例13: GetNewSEOState
/**
* 開始寫入資料
*/
private function GetNewSEOState()
{
$taskModel = new Task();
$date = new DateTime();
$taskModel->attributes = array('date' => $date->format("Y-m-d H:i:s"));
$taskModel->save();
$taskID = $taskModel->getPrimaryKey();
$this->GetSEOState($taskID);
}
示例14: store
/**
* Store a newly created resource in storage.
* POST /tasks
*
* @param Project $project
* @return Response
*/
public function store(Project $project)
{
$input = Input::all();
$input['project_id'] = $project->id;
$task = new Task($input);
if ($task->save()) {
return Redirect::route('projects.show', $project->slug)->with('message', 'Task created.');
} else {
return Redirect::route('projects.tasks.create', $project->slug)->withInput()->withErrors($task->errors());
}
}
示例15: run
public function run()
{
$task1 = new Task();
$task1->description = 'Do something';
$task1->list_id = 1;
$task1->save();
$task2 = new Task();
$task2->description = 'Do something else';
$task2->list_id = 1;
$task2->save();
}