本文整理汇总了PHP中Job::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Job::save方法的具体用法?PHP Job::save怎么用?PHP Job::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Job
的用法示例。
在下文中一共展示了Job::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createJob
/**
* Create a new job based on the PUT parameters given and content-type.
*
* @param $uri string The identifier of the job
*
* @return void
*/
public function createJob($uri)
{
list($collection_uri, $name) = $this->getParts($uri);
// Retrieve the parameters of the PUT requests (either a JSON document or a key=value string)
$params = \Request::getContent();
// Is the body passed as JSON, if not try getting the request parameters from the uri
if (!empty($params)) {
$params = json_decode($params, true);
} else {
$params = \Input::all();
}
// If we get empty params, then something went wrong
if (empty($params)) {
\App::abort(400, "The parameters could not be parsed from the body or request URI, make sure parameters are provided and if they are correct (e.g. correct JSON).");
}
// Validate the job properties
$job_params = $this->validateParameters('Job', 'job', $params);
// Check which parts are set for validation purposes
$extract = @$params['extract'];
$load = @$params['load'];
// Check for every emlp part if the type is supported
$extractor = $this->getClassOfType(@$extract, 'Extract');
$loader = $this->getClassOfType(@$load, 'Load');
// Save the emlp models
$extractor->save();
$loader->save();
// Create the job associated with emlp relations
$job = new \Job();
$job->collection_uri = $collection_uri;
$job->name = $name;
// Add the validated job params
foreach ($job_params as $key => $value) {
$job->{$key} = $value;
}
$job->extractor_id = $extractor->id;
$job->extractor_type = $this->getClass($extractor);
$job->loader_id = $loader->id;
$job->loader_type = $this->getClass($loader);
$job->save();
// Execute the job for a first time
$job->date_executed = time();
$job->save();
$job_name = $job->collection_uri . '/' . $job->name;
\Queue::push(function ($queued_job) use($job_name) {
\Artisan::call('input:execute', ['jobname' => $job_name]);
$queued_job->delete();
});
return \Response::make([], 200);
}
示例2: postAddJob
public function postAddJob()
{
$job = new Job();
$job->job = $_POST['name'];
$job->category_id = $_POST['cat_id'];
$job->save();
}
示例3: apply
public function apply()
{
$id = (int) $_POST['id'];
//find the offer
$market = new JobMarket();
$offer = $market->get($id);
if (empty($offer)) {
throw new Exception('offer not found');
}
//check if matches the requirements
$skill = new Skill();
$skill = $skill->get($this->user->id);
if ($skill->economic < $offer->skill) {
throw new Exception("you don't meet the requirements");
}
//give him the job
$data = array('uid' => $this->user->id, 'company' => $offer->company, 'salary' => $offer->salary);
$job = new Job($data);
$saved = $job->save();
// update the offer
if (!empty($saved)) {
$offer->quantity--;
if ($offer->quantity == 0) {
$offer->delete();
} else {
$offer->save();
}
return true;
} else {
return false;
}
}
示例4: save
/**
* Serialize the form into the database.
*
*/
public function save($con = null)
{
if ($this->getObject()) {
$j = $this->getObject();
} else {
$j = new Job();
}
$j->setPublicationId($this->getValue("publication_id"));
$j->setStatusId($this->getValue("status_id"));
$j->setEvent($this->getValue("event"));
$j->setDate($this->getValue("date"));
$j->setStartTime($this->getValue("start_time"));
$j->setEndTime($this->getValue("end_time"));
$j->setDueDate($this->getValue("due_date"));
$j->setContactName($this->getValue("contact_name"));
$j->setContactPhone($this->getValue("contact_phone"));
$j->setContactEmail($this->getValue("contact_email"));
$j->setAcctNum($this->getValue("acct_num"));
$j->save();
$logEntry = new Log();
$logEntry->setWhen(time());
$logEntry->setPropelClass("Job");
$logEntry->setSfGuardUserProfileId(sfContext::getInstance()->getUser()->getUserId());
$logEntry->setMessage("Basic info updated.");
$logEntry->setLogMessageTypeId(sfConfig::get("app_log_type_update"));
$logEntry->setPropelId($j->getId());
$logEntry->save();
}
示例5: index
/**
* @before _secure, _vendor
*/
public function index()
{
$this->seo(array("title" => "Schedule Your Appointments", "view" => $this->getLayoutView()));
$this->getLayoutView()->set("cal", true);
$view = $this->getActionView();
if (RequestMethods::post("appointment_id")) {
if (RequestMethods::post("job_id", "")) {
$job = Job::first(array("appointment_id = ?" => RequestMethods::post("appointment_id")));
$job->user_id = RequestMethods::post("user_id");
} else {
$job = new Job(array("user_id" => RequestMethods::post("user_id"), "muser_id" => RequestMethods::post("muser_id"), "puser_id" => RequestMethods::post("puser_id"), "appointment_id" => RequestMethods::post("appointment_id"), "location_id" => RequestMethods::post("location_id"), "centre_id" => RequestMethods::post("centre_id"), "organization_id" => RequestMethods::post("organization_id")));
}
$job->save();
$view->set("message", "Runner Assigned Successfully");
}
if (RequestMethods::post("action") == "capacity") {
foreach (RequestMethods::post("slot") as $key => $value) {
$slot = Slot::first(array("organization_id = ?" => $this->member->organization_id, "day = ?" => $key));
if (isset($slot)) {
$slot->start = $value["start"];
$slot->day = $key;
$slot->end = $value["end"];
$slot->capacity = $value["hlimit"];
} else {
$slot = new Slot(array("user_id" => $this->user->id, "organization_id" => $this->member->organization_id, "day" => $key, "start" => $value["start"], "end" => $value["end"], "capacity" => $value["hlimit"]));
}
$slot->save();
}
$view->set("message", "Slots Saved Successfully");
}
$runners = Member::all(array("organization_id = ?" => $this->member->organization_id, "designation = ?" => "runner"), array("user_id", "id"));
$view->set("runners", $runners);
$view->set("day", array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"));
$view->set("slots", Slot::all(array("organization_id = ?" => $this->member->organization_id), array("start", "end", "capacity", "day")));
}
示例6: run
public function run($arg)
{
try {
$arg = unserialize(base64_decode($arg));
if (!isset($arg['class']) || !isset($arg['function'])) {
return array('result' => array('done' => false, 'job_id' => -1), 'WorkerJobSetIdentifier' => isset($arg['WorkerJobSetIdentifier']) ? $arg['WorkerJobSetIdentifier'] : -1, 'background' => isset($arg['background']) ? $arg['background'] : -1);
}
$log = $arg["class"] . '::' . $arg["function"];
if (defined('THREAD') && defined('THREAD_TYPE')) {
print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n";
}
$task_id = $arg['task_id'];
$Job = Job::model()->find('id=:id', array(':id' => $task_id));
if ($Job == null) {
$Job = new Job();
return null;
}
$Job->started = 1;
$Job->starttime = date('Y-m-d H:i:s');
$Job->save();
$tmp = $this->runClassFunction($arg["class"], $arg["function"], $arg["params"]);
$done = false;
if ($tmp != null) {
$Job->parameters = null;
$Job->result = base64_encode(serialize($tmp));
$Job->finishtime = date('Y-m-d H:i:s');
$Job->save();
$Job->finished = 1;
$Job->save();
$done = true;
}
} catch (CDbException $e) {
if (function_exists('thread_shutdown')) {
thread_shutdown();
}
die;
}
$log = $arg["class"] . '::' . $arg["function"] . ' :: DONE';
if (defined('THREAD') && defined('THREAD_TYPE')) {
print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n";
}
return array('result' => array('done' => $done, 'job_id' => $Job->id), 'WorkerJobSetIdentifier' => $arg['WorkerJobSetIdentifier'], 'background' => $arg['background']);
}
示例7: createJob
public function createJob($type, $chart, $user, $params)
{
$job = new Job();
$job->setChartId($chart->getId());
$job->setUserId($user->getId());
$job->setCreatedAt(time());
$job->setType($type);
$job->setParameter(json_encode($params));
$job->save();
return $job;
}
示例8: executeAction
public function executeAction()
{
Assert::found($id = (int) $this->dispatcher->getParam('0', 'uint'));
Assert::found($task = Task::findFirst($id), "Task not found");
$job = Job::findFirst(['task_id = ?0 and executed_at is null', 'bind' => [$task->task_id]]);
if (!$job) {
$job = new Job();
$job->save(['task_id' => $task->task_id]);
Assert::noMessages($job);
}
return $this->response->redirect('/task/run/' . $job->job_id, true);
}
示例9: run
public function run()
{
$replace = \Config::get('laravel-jobs::seed.replace');
if ($replace) {
\DB::table('fbf_jobs')->delete();
}
$faker = \Faker\Factory::create();
$statuses = array(Job::DRAFT, Job::APPROVED);
$types = array(Job::PERMANENT, Job::TEMPORARY);
$times = array(Job::FULL_TIME, Job::PART_TIME);
for ($i = 0; $i < 100; $i++) {
$job = new Job();
$job->title = $faker->sentence(rand(1, 4));
if (\Config::get('laravel-jobs::use_reference_field')) {
$job->reference = 'JOB/' . rand(1000, 9999);
}
if (\Config::get('laravel-jobs::use_location_field')) {
$job->location = $faker->city();
}
if (\Config::get('laravel-jobs::use_type_field')) {
$job->type = $faker->randomElement($types);
}
if (\Config::get('laravel-jobs::use_time_field')) {
$job->time = $faker->randomElement($times);
}
if (\Config::get('laravel-jobs::use_closing_date_field')) {
$job->closing_date = $faker->dateTimeBetween('-1 week', '+3 months');
}
switch (\Config::get('laravel-jobs::salary_field')) {
case 'text':
$job->salary_text = $this->salaryText();
break;
case 'number':
$job->salary_from = rand(20000, 200000);
break;
case 'range':
$number1 = rand(20000, 200000);
$number2 = rand(20000, 200000);
$job->salary_from = min($number1, $number2);
$job->salary_to = max($number1, $number2);
break;
}
$job->description = '<p>' . implode('</p><p>', $faker->paragraphs(rand(1, 10))) . '</p>';
$job->meta_description = $faker->paragraph(rand(1, 4));
$keywords = $faker->words(10, true);
$job->search_extra = $keywords;
$job->meta_keywords = $keywords;
$job->status = $faker->randomElement($statuses);
$job->published_date = $faker->dateTimeBetween('-6 weeks', '+1 week');
$job->save();
}
echo 'Database seeded' . PHP_EOL;
}
示例10: schedule_recurring_event
function schedule_recurring_event($event)
{
global $wpdb;
$schedules = wp_get_schedules();
$schedule = $event->schedule;
$job = new Job();
$job->hook = $event->hook;
$job->site = get_current_blog_id();
$job->start = $job->nextrun = $event->timestamp;
$job->interval = $event->interval;
$job->args = $event->args;
$job->save();
}
示例11: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Job();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Job'])) {
$model->attributes = $_POST['Job'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例12: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Job();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Job'])) {
$model->attributes = $_POST['Job'];
if ($model->save()) {
EQuickDlgs::checkDialogJsScript();
$this->redirect(array('index'));
}
}
EQuickDlgs::render('create', array('model' => $model));
}
示例13: store
public function store()
{
$job = new Job();
$job->heading = Input::get('heading');
$job->description = Input::get('description');
$job->user_id = userId();
$job->salary_max = Input::get('salary_max');
$job->salary_min = Input::get('salary_min');
$job->start_date = Input::get('start_date');
$job->end_date = Input::get('end_date');
$job->state = Input::get('state');
$job->suburb = Input::get('suburb');
$update = $job->save();
return Response::json(['data' => $job], 200);
}
示例14: run
public function run()
{
$client = new Net_Gearman_Client(array('localhost:4730'));
$this->JobSet->starttime = date('Y-m-d H:i:s');
$this->JobSet->save();
$client->runSet($this->taskList);
if (!$this->background) {
if ($this->taskList->finished()) {
global $WorkerJobSetResults;
$handles = $this->taskList->handles;
$key_handles = array_keys($handles);
for ($i = 0; $i < count($WorkerJobSetResults[$this->randomHash]); $i++) {
if (array_key_exists($key_handles[$i], $WorkerJobSetResults[$this->randomHash])) {
if ($WorkerJobSetResults[$this->randomHash][$key_handles[$i]]['done']) {
$job = Job::model()->find('id=:id', array(':id' => $WorkerJobSetResults[$this->randomHash][$key_handles[$i]]['job_id']));
if ($job != null) {
if ($job == null) {
$job = new Job();
}
$this->results[] = unserialize(base64_decode($job->result));
// echo "Done";
$job->needed = 0;
$job->save();
} else {
die("Some results didn't come...\n");
}
}
} else {
die("Some results didn't come...\n");
}
}
$this->JobSet->finishtime = date('Y-m-d H:i:s');
if ($this->auto_destroy_results) {
$this->JobSet->needed = 0;
$this->JobSet->delete();
$this->JobSet = null;
} else {
$this->JobSet->save();
}
return $this->results;
}
echo "Task set could not be finished!<br />\n";
return false;
} else {
// background work
return true;
}
}
示例15: createJob
public function createJob($data, $jobgroup = null)
{
$data['queue'] = $this->_queue;
$data['jail'] = $this->_jail;
$job = new Job();
if ($job->setJobData($data) !== true) {
return false;
}
if ($job->save() !== true) {
return false;
}
if ($jobgroup == null) {
return true;
}
return $jobgroup->addJob($job->getJobId());
}