public function create(UploadRecord $record)
 {
     $this->_transaction->add("\n\t\t\tINSERT INTO\n\t\t\t\tproduct_page_upload_record\n\t\t\t\t(\n\t\t\t\t\tpage_id,\n\t\t\t\t\tproduct_id,\n\t\t\t\t\tunit_id,\n\t\t\t\t\tconfirmed_at,\n\t\t\t\t\tconfirmed_by\n\t\t\t\t)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:pageID?i,\n\t\t\t\t\t:productID?in,\n\t\t\t\t\t:unitID?in,\n\t\t\t\t\t:confirmedAt?dn,\n\t\t\t\t\t:confirmedBy?in\n\t\t\t\t)\n\t\t", ['pageID' => $record->getPageID(), 'productID' => $record->getProductID(), 'unitID' => $record->getUnitID(), 'confirmedAt' => $record->getConfirmedAt(), 'confirmedBy' => $record->getConfirmedBy()]);
     if (!$this->_transOverride) {
         $this->_transaction->commit();
     }
 }
 /**
  * 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();
 }
    /**
     * Add query saving the referral to the database transaction
     *
     * @param ReferralInterface $referral
     */
    private function _addToTransaction(ReferralInterface $referral)
    {
        $this->_trans->add('
			UPDATE
				refer_a_friend_referral
			SET
				status         = :status?s,
				referrer_id    = :referrerID?i,
				referred_email = :referredEmail?s,
				updated_at     = :updatedAt?d,
				updated_by     = :updatedBy?in
			WHERE
				referral_id = :id?i
		', ['status' => $referral->getStatus(), 'referrerID' => $referral->getReferrer()->id, 'referredEmail' => $referral->getReferredEmail(), 'updatedAt' => new \DateTime(), 'updatedBy' => $this->_currentUser->id, 'id' => $referral->getID()]);
    }
 /**
  * Save data to product export table, create new row if not exists
  *
  * @throws \LogicException
  *
  * @return Edit
  */
 protected function _saveProductExport()
 {
     if (!$this->_product) {
         throw new \LogicException('Cannot edit product export info as no product is set');
     }
     $this->_trans->add("\n\t\t\tINSERT INTO\n\t\t\t\tproduct_export\n\t\t\t\t(\n\t\t\t\t\tproduct_id,\n\t\t\t\t\tlocale,\n\t\t\t\t\texport_value,\n\t\t\t\t\texport_description,\n\t\t\t\t\texport_manufacture_country_id,\n\t\t\t\t\texport_code\n\t\t\t\t)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:productID?i,\n\t\t\t\t\t:locale?sn,\n\t\t\t\t\t:exportValue?fn,\n\t\t\t\t\t:exportDescription?sn,\n\t\t\t\t\t:exportCountryID?s,\n\t\t\t\t\t:exportCode?sn\n\t\t\t\t)\n\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\texport_value\t\t\t\t\t= :exportValue?fn,\n\t\t\t\texport_description\t\t\t\t= :exportDescription?sn,\n\t\t\t\texport_manufacture_country_id\t= :exportCountryID?s,\n\t\t\t\texport_code                     = :exportCode?sn\n\t\t", ['productID' => $this->_product->id, 'locale' => $this->_locale->getID(), 'exportValue' => $this->_product->exportValue, 'exportDescription' => $this->_product->exportDescription, 'exportCountryID' => $this->_product->exportManufactureCountryID, 'exportCode' => $this->_product->getExportCode()]);
     return $this;
 }
 /**
  * Loop through unit IDs and save them with the page ID and product ID
  *
  * @param Page $page                         The product page being edited
  * @param Product $product                   The product assigned to the page
  * @param array | Unit\Collection $units     The units that fit the requirements of the page
  * @param bool $deleteExisting               Determines whether existing rows should be deleted before
  *                                           save, defaults to true
  */
 public function save(Page $page, Product $product, $units, $deleteExisting = true)
 {
     if (!is_array($units) && !$units instanceof Unit\Collection) {
         throw new \InvalidArgumentException('Units must be either an array or a Unit\\Collection instance');
     }
     if ($deleteExisting) {
         $this->_transaction->add("\n\t\t\t\tDELETE FROM\n\t\t\t\t\tproduct_page_unit_record\n\t\t\t\tWHERE\n\t\t\t\t\tpage_id = :pageID?i\n\t\t\t", ['pageID' => $page->id]);
     }
     if (count($units) > 0) {
         $inserts = [];
         $params = ['pageID' => $page->id, 'productID' => $product->id];
         foreach ($units as $unit) {
             $inserts[] = '(' . PHP_EOL . ':pageID?i,' . PHP_EOL . ':productID?i,' . PHP_EOL . ':unitID' . $unit->id . '?i' . PHP_EOL . ')';
             $params['unitID' . $unit->id] = $unit->id;
         }
         $inserts = implode(',' . PHP_EOL, $inserts);
         $this->_transaction->add("\n\t\t\t\tREPLACE INTO\n\t\t\t\t\tproduct_page_unit_record\n\t\t\t\t\t(\n\t\t\t\t\t\tpage_id,\n\t\t\t\t\t\tproduct_id,\n\t\t\t\t\t\tunit_id\n\t\t\t\t\t)\n\t\t\t\tVALUES\n\t\t" . $inserts, $params);
     }
     $this->_commitTransaction();
 }
 /**
  * Add a query saving a trigger to the database transaction
  *
  * @param ConfigInterface $config
  * @param TriggerInterface $trigger
  */
 private function _addToTransaction(ConfigInterface $config, TriggerInterface $trigger)
 {
     $this->_transaction->add("\n\t\t\tINSERT INTO\n\t\t\t\trefer_a_friend_reward_trigger\n\t\t\t\t(\n\t\t\t\t\treward_config_id,\n\t\t\t\t\t`name`\n\t\t\t\t)\n\t\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:rewardConfigID?i,\n\t\t\t\t\t:name?s\n\t\t\t\t)\n\t\t", ['rewardConfigID' => $config->getID(), 'name' => $trigger->getName()]);
 }
 /**
  * Add a query to save an individual comment to the transaction
  *
  * @param Comment $comment
  * @param UserInterface $user
  */
 private function _save(Comment $comment, UserInterface $user)
 {
     $this->_trans->add("\n\t\t\tUPDATE\n\t\t\t\tblog_comment\n\t\t\tSET\n\t\t\t\tpage_id       = :pageID?i,\n\t\t\t\tuser_id       = :userID?i,\n\t\t\t\t`name`        = :name?s,\n\t\t\t\temail_address = :email?s,\n\t\t\t\twebsite       = :website?sn,\n\t\t\t\tcontent       = :content?s,\n\t\t\t\tip_address    = :ipAddress?s,\n\t\t\t\tupdated_at    = :updatedAt?d,\n\t\t\t\tupdated_by    = :updatedBy?in,\n\t\t\t\tstatus        = :status?s\n\t\t\tWHERE\n\t\t\t\tcomment_id    = :id?i\n\t\t", ['id' => $comment->getID(), 'pageID' => $comment->getPageID(), 'userID' => $comment->getUserID(), 'name' => $comment->getName(), 'email' => $comment->getEmail(), 'website' => $comment->getWebsite(), 'content' => $comment->getContent(), 'ipAddress' => $comment->getIpAddress(), 'updatedAt' => new \DateTime(), 'updatedBy' => $user->id, 'status' => $comment->getStatus()]);
 }
 /**
  * Add the query to delete a configuration to the database transaction
  *
  * @param Config $config
  */
 private function _addToTransaction(Config $config)
 {
     $this->_transaction->add("\n\t\t\tUPDATE\n\t\t\t\trefer_a_friend_reward_config\n\t\t\tSET\n\t\t\t\tdeleted_at    = :deletedAt?d,\n\t\t\t\tdeleted_by    = :deletedBy?i\n\t\t\tWHERE\n\t\t\t\treward_config_id = :id?i\n\t\t", ['id' => $config->getID(), 'deletedAt' => new \DateTime(), 'deletedBy' => $this->_currentUser->id]);
 }
 /**
  * Add query saving the constraint name and value, as well as the reward config ID, to the database transaction
  *
  * @param ConfigInterface $config
  * @param ConstraintInterface $constraint
  */
 private function _addToTransaction(ConfigInterface $config, ConstraintInterface $constraint)
 {
     $this->_transaction->add("\n\t\t\tINSERT INTO\n\t\t\t\trefer_a_friend_reward_constraint\n\t\t\t\t(\n\t\t\t\t\treward_config_id,\n\t\t\t\t\t`name`,\n\t\t\t\t\t`value`\n\t\t\t\t)\n\t\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:rewardConfigID?i,\n\t\t\t\t\t:name?s,\n\t\t\t\t\t:value?s\n\t\t\t\t)\n\t\t", ['rewardConfigID' => $config->getID(), 'name' => $constraint->getName(), 'value' => $constraint->getValue()]);
 }
예제 #10
0
 /**
  * Save the type against the user
  *
  * @param User\User $user
  * @param UserTypeInterface $type
  *
  * @return UserTypeInterface
  */
 public function save(User\User $user, UserTypeInterface $type)
 {
     $this->_transaction->add("\n\t\t\tREPLACE INTO\n\t\t\t\tuser_type\n\t\t\t\t(\n\t\t\t\t\tuser_id,\n\t\t\t\t\t`type`\n\t\t\t\t)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:id?i,\n\t\t\t\t\t:type?s\n\t\t\t\t)\n\t\t", ['id' => $user->id, 'type' => $type->getName()]);
     $this->_commitTransaction();
     return $type;
 }