/**
  * If table key (id) is NULL : inserts a new row
  * otherwise updates existing row in the database table
  *
  * Can be overridden or overloaded by the child class
  *
  * @param  boolean  $updateNulls  TRUE: null object variables are also updated, FALSE: not.
  * @return boolean                TRUE if successful otherwise FALSE
  */
 public function store($updateNulls = false)
 {
     $key = $this->_tbl_key;
     if (!$this->{$key}) {
         $this->event_time = $this->_db->getUtcDateTime();
         $this->user_id = Application::MyUser()->getUserId();
         $this->ip_addresses = cbpaidRequest::getIPlist();
         $this->log_version = 1;
     }
     return parent::store($updateNulls);
 }
Exemplo n.º 2
0
	/**
	 * If table key (id) is NULL : inserts a new row
	 * otherwise updates existing row in the database table
	 *
	 * Can be overridden or overloaded by the child class
	 *
	 * @param  boolean  $updateNulls  TRUE: null object variables are also updated, FALSE: not.
	 * @return boolean                TRUE if successful otherwise FALSE
	 */
	public function store( $updateNulls = false ) {
		global $_CB_framework;

		$key						=	$this->_tbl_key;
		if ( ! $this->$key ) {
			$this->event_time		=	date( 'Y-m-d H:i:s', $_CB_framework->now() );
			$this->user_id			=	$_CB_framework->myId();
			$this->ip_addresses		=	cbpaidRequest::getIPlist();
			$this->log_version		=	1;
		}
		return parent::store( $updateNulls );
	}
	/**
	 * Stores the object, in this case also converting the parameter objects (integrations) into storable columns
	 *
	 * @param  boolean  $updateNulls  TRUE: null object variables are also updated, FALSE: not.
	 * @return boolean                TRUE if successful otherwise FALSE
	 */
	public function store( $updateNulls = false ) {
		$this->storeParams();
		return parent::store( $updateNulls );
	}
Exemplo n.º 4
0
	/**
	 * Stores subscription only if needed, according to global setting createAlsoFreeSubscriptions
	 *
	 * @param  boolean  $updateNulls  TRUE: null object variables are also updated, FALSE: not.
	 * @return boolean                TRUE if successful otherwise FALSE
	 */
	public function store( $updateNulls = false ) {
		// Clears the cache of the subscriptions for that user id, so next fetch is updated as well:
		$paidUserExtension			=&	cbpaidUserExtension::getInstance( $this->user_id );
		$paidUserExtension->getUserSubscriptions( 'clearcache' );

		return parent::store( $updateNulls );
	}
 /**
  * Stores $this into database:
  * - try to update by id if known, otherwise by currency codes pair
  * - inserts if not existant
  *
  * @param  boolean  $updateNulls   Update also NULLs of $this in database
  * @return boolean                 Result: TRUE: OK, FALSE: error in database
  */
 public function store($updateNulls = false)
 {
     $k = $this->_tbl_key;
     if ($this->{$k}) {
         $sql = "SELECT " . $this->_tbl_key . " FROM " . $this->_tbl . "\n WHERE " . $this->_tbl_key . " = " . (int) $this->{$k};
     } else {
         $sql = "SELECT " . $this->_tbl_key . " FROM " . $this->_tbl . "\n WHERE base_currency = '" . $this->_db->getEscaped($this->base_currency) . "'" . "\n AND currency = '" . $this->_db->getEscaped($this->currency) . "'";
     }
     $this->_db->SetQuery($sql);
     $idArrays = $this->_db->loadResultArray();
     if (count($idArrays) > 0) {
         // existing record:
         if (!$this->{$k}) {
             $this->{$k} = $idArrays[0];
         }
         $ret = parent::store($updateNulls);
     } else {
         // new record
         $sql = "SELECT MAX(ordering) FROM " . $this->_tbl;
         $this->_db->SetQuery($sql);
         $max = $this->_db->LoadResult();
         $this->ordering = $max + 1;
         $this->{$k} = null;
         $ret = parent::store($updateNulls);
     }
     return $ret;
 }