Beispiel #1
0
 /**
  * Commit changes to this locomotive
  * @since Version 3.9.1
  * @return \Railpage\Locos\Date
  */
 public function commit()
 {
     $this->validate();
     $data = array("loco_unit_id" => $this->Loco->id, "loco_date_id" => $this->action_id, "date" => $this->Date->getTimestamp(), "date_end" => $this->DateEnd instanceof DateTime ? $this->DateEnd->format("Y-m-d") : NULL, "timestamp" => $this->Date->format("Y-m-d"), "text" => $this->text, "meta" => json_encode($this->meta));
     if (filter_var($this->id)) {
         $this->Redis->delete($this->mckey);
         $where = array("date_id = ?" => $this->id);
         $this->db->update("loco_unit_date", $data, $where);
     } else {
         $this->db->insert("loco_unit_date", $data);
         $this->id = $this->db->lastInsertId();
     }
     if (isset($this->Loco->meta['construction_cost'])) {
         $this->Loco->meta['construction_cost_inflated'] = ContentUtility::convertCurrency($this->Loco->meta['construction_cost'], Utility\LocomotiveUtility::getConstructionDate($this->Loco));
         $this->Loco->commit();
     }
     return $this;
 }
Beispiel #2
0
 /**
  * @depends testAddLocoClass
  * @depends testAddGauge
  * @depends testAddStatus
  */
 public function test_add_loco_class_a($class_id, $gauge_id, $status_id)
 {
     $Loco = new Locomotive();
     $Loco->class = new LocoClass($class_id);
     $Loco->setGauge(new Gauge($gauge_id));
     $Loco->number = "1233";
     $Loco->status_id = $status_id;
     $Loco->commit();
     $Loco = new Locomotive();
     $Loco->class_id = $class_id;
     $Loco->setGauge(new Gauge($gauge_id));
     $Loco->number = "1234";
     $Loco->status_id = $status_id;
     $Loco->commit();
 }