本文整理汇总了PHP中Skill::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Skill::save方法的具体用法?PHP Skill::save怎么用?PHP Skill::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skill
的用法示例。
在下文中一共展示了Skill::save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveSkill
public function saveSkill(Skill $skill)
{
try {
$skill->save();
} catch (Exception $e) {
throw new DaoException($e->getMessage(), $e->getCode(), $e);
}
}
示例2: train
/**
* User goes gym and trains
*
* @return mixed (array/boolean)
*/
public function train()
{
/*
Session 1-4 100 strength gain per day
Session 5-14 50 strength gain per day
Session 15-34 25 strength gain per day
Session 35-64 10 strength gain per day
Session 65-124 5 strength gain per day
Session 125-199 2 strength gain per day
Session 200+ 1 strength gain per day
*/
$r = Service::getDB()->query("SELECT uid FROM `train_historial` WHERE uid = '" . $this->id . "'");
$trainedDays = sizeof($r);
if ($trainedDays < 5) {
$strengh = 100;
} elseif ($trainedDays < 15) {
$strengh = 50;
} elseif ($trainedDays < 35) {
$strengh = 25;
} elseif ($trainedDays < 65) {
$strengh = 10;
} elseif ($trainedDays < 125) {
$strengh = 5;
} elseif ($trainedDays < 200) {
$strengh = 2;
} else {
$strengh = 1;
}
$skill = new Skill();
$skill->get($this->id);
$skill->strengh += $strengh;
if ($skill->save()) {
Service::getDB()->insert('train_historial', array('uid' => $this->id, 'date' => $this->now()));
$trainedDays++;
return array('strengh' => $strengh, 'trainedDays' => $trainedDays);
} else {
return false;
}
}
示例3: envSkills
protected function envSkills()
{
$skill = new Skill();
$skill->skill_title = 'PHP';
$skill->percent = '70';
$skill->description_title = 'My Skills';
$skill->description = 'Are Sweet';
$skill->template_id = 1;
$skill->save();
$skill11 = new Skill();
$skill11->skill_title = 'Javascript';
$skill11->percent = '50';
$skill11->description_title = 'My Skills';
$skill11->description = 'Are Sweet';
$skill11->template_id = 1;
$skill11->save();
$skill12 = new Skill();
$skill12->skill_title = 'CSS';
$skill12->percent = '50';
$skill12->description_title = 'My Skills';
$skill12->description = 'Are Sweet';
$skill12->template_id = 1;
$skill12->save();
$skill2 = new Skill();
$skill2->skill_title = 'PHP';
$skill2->percent = '20';
$skill2->description_title = 'My Skills';
$skill2->description = 'Are Sweet';
$skill2->template_id = 2;
$skill2->save();
$skill3 = new Skill();
$skill3->skill_title = 'PHP';
$skill3->percent = '20';
$skill3->description_title = 'My Skills';
$skill3->description = 'Are Sweet';
$skill3->template_id = 3;
$skill3->save();
}
示例4: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aUser !== null) {
if ($this->aUser->isModified() || $this->aUser->isNew()) {
$affectedRows += $this->aUser->save($con);
}
$this->setUser($this->aUser);
}
if ($this->aSkill !== null) {
if ($this->aSkill->isModified() || $this->aSkill->isNew()) {
$affectedRows += $this->aSkill->save($con);
}
$this->setSkill($this->aSkill);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例5: function
$data['skills'] = Skill::all();
$app->render('skills/overview.html', $data);
})->name('skills_overview');
$app->map('/delete/:id', function ($id) use($app, $data) {
$data['skill'] = Skill::find($id);
if ($app->request->isPost()) {
$data['skill']->delete();
}
$app->render('skills/delete.html', $data);
})->via('GET', 'POST')->name('skills_delete');
$app->map('/new', function () use($app, $data) {
if ($app->request->isPost()) {
$edu_level = EducationLevel::find($app->request->post('educationlevel'));
$skill = new Skill();
$skill->name = $app->request->post('title');
$skill->save();
$data['new_skill'] = $skill;
}
$app->render('skills/new.html', $data);
})->via('GET', 'POST')->name('skills_new');
$app->map('/edit/:id', function ($id) use($app, $data) {
$data['request_method'] = $app->request->getMethod();
$skill = Skill::find($id);
if ($app->request->isGet()) {
$data['skill'] = $skill->toArray();
} else {
if ($app->request->isPost()) {
$skill->name = $app->request->post('title');
$skill->save();
$data['new_skill'] = $skill->toArray();
}
示例6: work
/**
* Generates units from user work and pays his salary
*
* @return mixed (boolean/array)
*/
public function work()
{
/*
http://wiki.e-sim.org/index.php/Productivity_formula
* P = 10 * (4+E) * N * C * R * Q
P - Productivity
E - Economy skill level
N - Employee multiplier (Number of employees already worked that day in the company.)
if employeesWorked <=10 Then N = 1.0 + (10-employeesWorked) * 0.05
elseif employeesWorked <=20 Then N = 1.0 - (employeesWorked-10) * 0.03
elseif employeesWorked <=30 Then N = 0.7 - (employeesWorked-20) * 0.02
else N=0.5;
C
1 If home country controls capital
0.75 If not
R
for manufacture companies:
1.25 If region's country owns the appropriate high raw. (eg: Iron for Weapons)
1 If region's country do not own the appropriate high raw.
for raw companies:
1.0 in high regions
0.75 in medium region.
Q
1.0 for manufacture companies
for raw companies
1.0 for Q1 companies
1.2 for Q2 companies
1.4 for Q3 companies
1.6 for Q4 companies
1.8 for Q5 companies
*
*/
$job = new Job();
$job = $job->getByUid($this->uid);
if (!$job) {
throw new Exception("you don't have a job");
}
$skills = new Skill();
$skills->get($this->uid);
$E = $skills->economic;
$employeesWorked = 1;
//ToDO PENDING
if ($employeesWorked <= 10) {
$N = 1.0 + (10 - $employeesWorked) * 0.05;
} elseif ($employeesWorked <= 20) {
$N = 1.0 - ($employeesWorked - 10) * 0.03;
} elseif ($employeesWorked <= 30) {
$N = 0.7 - ($employeesWorked - 20) * 0.02;
} else {
$N = 0.5;
}
$company = new Company();
$company->get($job->company);
$region = new Region();
$companyRegion = $region->get($company->region);
//does the region have the resource that company produces?
// also determine product quality
if ($company->productType == Company::PRODUCT_TYPE_RESOURCE) {
$R = $companyRegion->resourceAmount / 10;
$Q = 1;
} else {
$product = new Product();
$product->get($company->product);
if ($companyRegion->resourceType == $product->resource) {
$R = 1.25;
} else {
$R = 1;
}
$Q = 0.8 + 0.2 * $company->quality;
}
$country = new Country();
$country = $country->get($companyRegion->country);
$capitalRegion = $region->get($country->capitalRegionId);
//is country capital owned by original owners?
if ($capitalRegion->country == $capitalRegion->countryConqueror) {
$C = 1;
} else {
$C = 0.75;
}
if ($companyRegion->resourceAmount > 0) {
$productivity = 10 * (4 + $E) * $N * $C * $R * $Q;
} else {
$productivity = 10 * (4 + $E) * $N * $C * $Q;
}
$user = new User($this->uid);
$user->updateXP('WORK');
$skills->economic += 0.125;
$skills->save();
$company->pendingUnits += $productivity;
//calculate produced units
if ($company->productType == Company::PRODUCT_TYPE_RESOURCE) {
$createdUnits = floor($company->pendingUnits);
$company->pendingUnits -= $createdUnits;
$added = $company->addStock($createdUnits, Company::PRODUCT_TYPE_PRODUCT);
if ($added) {
//.........这里部分代码省略.........
示例7: testGetSkills
function testGetSkills()
{
//Arrange
$description_id = 1;
$race_id = 1;
$stat_id = 1;
$test_character = new Character($description_id, $race_id, $stat_id);
$test_character->save();
$name = "Acrobatics";
$description = "stuff";
$id = 1;
$test_skill = new Skill($name, $description, $id);
$test_skill->save();
$name2 = "Athletics";
$description2 = "other stuff";
$id2 = 2;
$test_skill2 = new Skill($name2, $description2, $id2);
$test_skill2->save();
//Act
$test_character->addSkill($test_skill);
$test_character->addSkill($test_skill2);
//Assert
$this->assertEquals($test_character->getSkills(), [$test_skill, $test_skill2]);
}
示例8: Skill
function test_find()
{
//Arrange
$name = "Acrobatics";
$description = "stuff";
$id = 1;
$test_class = new Skill($name, $description, $id);
$test_class->save();
$name2 = "Athletics";
$description2 = "other stuff";
$id2 = 2;
$test_class2 = new Skill($name2, $description2, $id2);
$test_class2->save();
//Act
$result = Skill::find($test_class->getId());
//Assert
$this->assertEquals($test_class, $result);
}
示例9: store
/**
* Store a newly created template in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Template::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
} else {
$template = new Template();
$template->color = Input::get('color');
$template->layout = Input::get('templateID');
$template->user_id = Auth::id();
$template->save();
//Storing header info
if (Input::has('headerJobTitle')) {
$header = new Header1();
$header->job_title = Input::get('headerJobTitle');
$header->template_id = $template->id;
if (Input::has('headerResumeTitle')) {
$header->description = Input::get('headerResumeTitle');
}
if (Input::hasFile('headerImage')) {
$header->picture = Input::file('headerImage')->move("images/uploaded/");
}
if (Input::has('headerJobTitle')) {
$header->description = Input::get('headerJobTitle');
}
$header->save();
}
//Storing adjectives for template 2
if (Input::has('adjectives1')) {
$header1 = new Header1();
$header1->template_id = $template->id;
$header1->adjective = Input::get('adjectives1');
$header1->save();
}
if (Input::has('adjectives2')) {
$header2 = new Header1();
$header2->template_id = $template->id;
$header2->adjective = Input::get('adjectives2');
$header2->save();
}
if (Input::has('adjectives3')) {
$header3 = new Header1();
$header3->template_id = $template->id;
$header3->adjective = Input::get('adjectives3');
$header3->save();
}
//Checking for up to 6 skill inputs to be accpeted
if (Input::has('skillPercent1') && Input::has('skillTitle1')) {
$skill1 = new Skill();
$skill1->template_id = $template->id;
$skill1->percent = Input::get('skillPercent1');
$skill1->skill_title = Input::get('skillTitle1');
if (Input::has('skillDescription1')) {
$skill1->description = Input::get('skillDescription1');
}
if (Input::has('skillDescriptionTitle1')) {
$skill1->description_title = Input::get('skillDescriptionTitle1');
}
if (Input::has('hobbies1')) {
$skill1->description_title = Input::get('hobbies1');
}
$skill1->save();
}
if (Input::has('skillPercent2') && Input::has('skillTitle2')) {
$skill2 = new Skill();
$skill2->template_id = $template->id;
$skill2->percent = Input::get('skillPercent2');
$skill2->skill_title = Input::get('skillTitle2');
if (Input::has('skillDescription2')) {
$skill2->description = Input::get('skillDescription2');
}
if (Input::has('skillDescriptionTitle2')) {
$skill2->description_title = Input::get('skillDescriptionTitle2');
}
if (Input::has('hobbies2')) {
$skill2->description_title = Input::get('hobbies2');
}
$skill2->save();
}
if (Input::has('skillPercent3') && Input::has('skillTitle3')) {
$skill3 = new Skill();
$skill3->template_id = $template->id;
$skill3->percent = Input::get('skillPercent3');
$skill3->skill_title = Input::get('skillTitle3');
if (Input::has('skillDescription3')) {
$skill3->description = Input::get('skillDescription3');
}
if (Input::has('skillDescriptionTitle3')) {
$skill3->description_title = Input::get('skillDescriptionTitle3');
}
if (Input::has('hobbies3')) {
$skill3->description_title = Input::get('hobbies3');
}
$skill3->save();
}
//.........这里部分代码省略.........
示例10: addData
static function addData()
{
// SKILLS:
$skill1 = new Skill("Acrobatics", "Balancing and tumbling", 1);
$skill2 = new Skill("Animal Handling", "Using or interacting with domesticated animals.", 2);
$skill3 = new Skill("Arcana", "Magic related lore and knowledge.", 3);
$skill4 = new Skill("Athletics", "Climbing, jumping, and swimming.", 4);
$skill5 = new Skill("Deception", "Hide the truth.", 5);
$skill6 = new Skill("History", "Recall historical events.", 6);
$skill7 = new Skill("Insight", "Determine a creature's true intentions.", 7);
$skill8 = new Skill("Intimidation", "Influence by using threats.", 8);
$skill9 = new Skill("Investigation", "Look for clues and find hidden things.", 9);
$skill10 = new Skill("Medicine", "Stabilize the dying or diagnose a disease.", 10);
$skill11 = new Skill("Nature", "Recall weather, plant, or animal lore.", 11);
$skill12 = new Skill("Perception", "See, hear, or smell the presence or something.", 12);
$skill13 = new Skill("Performance", "Ability in dancing, singing, or storytelling.", 13);
$skill14 = new Skill("Persuasion", "Influence by using goodwill.", 14);
$skill15 = new Skill("Religion", "Recall religious lore.", 15);
$skill16 = new Skill("Sleight of Hand", "Concealing items or stealing things.", 16);
$skill17 = new Skill("Stealth", "Sneaking or hiding.", 17);
$skill18 = new Skill("Survival", "Track and hunt, avoid hazards, or predict weather.", 18);
$skill1->save();
$skill2->save();
$skill3->save();
$skill4->save();
$skill5->save();
$skill6->save();
$skill7->save();
$skill8->save();
$skill9->save();
$skill10->save();
$skill11->save();
$skill12->save();
$skill13->save();
$skill14->save();
$skill15->save();
$skill16->save();
$skill17->save();
$skill18->save();
// RACES:
$race1 = new Race("Good all around, well balanced, adventurer. Easy to role play and fits most roles well.", "Human", 1);
$race2 = new Race("Tough and wise. Good clerics. Bearded and can live to over 400. A bit more open than mountain dwarves.", "Hill Dwarf", 2);
$race3 = new Race("Strong and tough. Good fighters. Bearded and can live to over 400. Likes to keep to their own.", "Mountain Dwarf", 3);
$race4 = new Race("Fast and intelligent. Good fighters, rogues or wizards. Bronze skin. Has air of superiority.", "High Elf", 4);
$race5 = new Race("Fast and wise. Good clerics and fighters. Copper/green skin. Very in tune with nature.", "Wood Elf", 5);
$race6 = new Race("Fast and charismatic. Good rogues. Easily overlooked. Wanderers. Around 3 feet tall.", "Lightfoot Halfling", 6);
$race7 = new Race("Tough and fast. Good fighters or rogues. Strong natured and boisterous.", "Stout Halfling", 7);
$race1->save();
$race2->save();
$race3->save();
$race4->save();
$race5->save();
$race6->save();
$race7->save();
// CLASSES:
$class1 = new CharClass("Cleric", "Wise and charismatic. Typically a healer who wields divine power in the service of their diety.", 1);
$class2 = new CharClass("Fighter", "Strong and tough or fast and tough. Master of combat and knowledgable in weapons and armor.", 2);
$class3 = new CharClass("Rogue", "Fast and intelligent. Highly skilled and commonly duplicitous. Commonly a seeker of treasures.", 3);
$class4 = new CharClass("Wizard", "Intelligent and wise. Weaves magic spells that manipulate reality using long studied arcane knowledge.", 4);
$class1->save();
$class2->save();
$class3->save();
$class4->save();
// BACKGROUNDS:
$background1 = new Background("Hermit", "Medicine and religion. Your life has been lonely and you have a secret knowledge.", 1);
$background2 = new Background("Noble", "History and persuasion. Your life has been luxurious and you benefit from your position of privilege.", 2);
$background3 = new Background("Soldier", "Athletics and intimidation. Your life has been touched by war and you are recognized by your military rank.", 3);
$background4 = new Background("Urchin", "Sleight of Hand and Stealth. Your life has been impoverished and you are intimately familiar with city workings.", 4);
$background1->save();
$background2->save();
$background3->save();
$background4->save();
}