コード例 #1
0
 /**
  * Save changes to the bundle to the database
  *
  * @param Bundle $bundle
  */
 public function save(Bundle $bundle)
 {
     $this->_transaction->add("\n\t\t\tUPDATE\n\t\t\t\tdiscount_bundle\n\t\t\tSET\n\t\t\t\t`name` = :name?s,\n\t\t\t\tallow_codes = :allowsCodes?b,\n\t\t\t\tstart = :start?dn,\n\t\t\t\t`end` = :end?dn,\n\t\t\t\tupdated_at = :updatedAt?d,\n\t\t\t\tupdated_by = :updatedBy?i\n\t\t\tWHERE\n\t\t\t\tbundle_id = :bundleID?i\n\t\t", ['name' => $bundle->getName(), 'allowsCodes' => $bundle->allowsCodes(), 'start' => $bundle->getStart(), 'end' => $bundle->getEnd(), 'updatedAt' => new \DateTime(), 'updatedBy' => $this->_user->id, 'bundleID' => $bundle->getID()]);
     $this->_productCreate->save($bundle);
     $this->_priceCreate->setTransaction($this->_transaction);
     $this->_priceCreate->save($bundle);
     $this->_imageCreate->setTransaction($this->_transaction);
     $this->_imageCreate->save($bundle);
     $this->_commitTransaction();
 }
コード例 #2
0
 /**
  * Save bundle to the database
  *
  * @param Bundle $bundle
  *
  * @return Bundle           Return Bundle with ID and authorship details updated.
  */
 public function save(Bundle $bundle)
 {
     if (!$bundle->getAuthorship()->createdAt()) {
         $bundle->getAuthorship()->create(new DateTimeImmutable(), $this->_user->id);
     }
     $result = $this->_query->run("\n\t\t\tINSERT INTO\n\t\t\t\tdiscount_bundle\n\t\t\t\t(\n\t\t\t\t\t`name`,\n\t\t\t\t\tallow_codes,\n\t\t\t\t\tstart,\n\t\t\t\t\t`end`,\n\t\t\t\t\tcreated_at,\n\t\t\t\t\tcreated_by\n\t\t\t\t)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:name?s,\n\t\t\t\t\t:allowsCodes?b,\n\t\t\t\t\t:start?dn,\n\t\t\t\t\t:end?dn,\n\t\t\t\t\t:createdAt?d,\n\t\t\t\t\t:createdBy?i\n\t\t\t\t)\n\t\t", ['name' => $bundle->getName(), 'allowsCodes' => $bundle->allowsCodes(), 'start' => $bundle->getStart(), 'end' => $bundle->getEnd(), 'createdAt' => new \DateTime(), 'createdBy' => $this->_user->id]);
     $bundle->setID($result->id());
     $this->_bundleProductCreate->save($bundle);
     $this->_bundlePriceCreate->save($bundle);
     $this->_bundleImageCreate->save($bundle);
     return $bundle;
 }