/**
  * Set the value of the attribute of this timed item
  *
  * @param  string  $column  Name of attribute
  * @param  mixed   $value   Nalue to assign to attribute
  */
 public function set($column, $value)
 {
     if (!property_exists($this, $column)) {
         trigger_error('cbpaidTimed::set ("' . htmlspecialchars($column) . '") innexistant attribute.', E_USER_ERROR);
     }
     parent::set($column, $value);
 }
예제 #2
0
	/**
	 * Logs error into logs database
	 *
	 * @param  int               $log_priority  Priority of message (UNIX-type): 0: Emergency, 1: Alert, 2: Critical, 3: Error, 4: Warning, 5: Notice, 6: Info, 7: Debug
	 * @param  string            $message       The error message (simple non-html text only)
	 * @param  cbpaidTable|null  $object        Object stored in database, so that table name of table and id of key can be stored with the error
	 * @return void
	 */
	public function logError( $log_priority, $message, $object ) {
		$this->event_type			=	1;
		$this->log_priority			=	(int) $log_priority;
		$this->message				=	$message;
		if ( $object instanceof TableInterface ) {
			$this->table_name			=	$object->getTableName();
			$k							=	$object->getKeyName();
			$this->table_key_id			=	(int) $object->$k;
		} elseif ( is_object( $object ) && isset( $object->_tbl ) && isset( $object->_tbl_key ) ) {
			$this->table_name			=	$object->_tbl;
			$k							=	$object->_tbl_key;
			$this->table_key_id			=	(int) $object->$k;
		}
		$errorNum					=	$this->_db->getErrorNum();
		$errorMsg					=	$this->_db->getErrorMsg();
		$this->store();
		$this->_db->setErrorNum( $errorNum );
		$this->_db->setErrorMsg( $errorMsg );
	}
 /**
  * Constructor
  *
  * @param  CBdatabase  $db
  */
 public function __construct(&$db = null)
 {
     parent::__construct('NONE', 'id', $db);
 }
예제 #4
0
	/**
	 * Constructor
	 *
	 *	@param string      $table  name of the table in the db schema relating to child class
	 *	@param string      $key    name of the primary key field in the table
	 *	@param CBdatabase  $db     CB Database object
	 */
	public function __construct( $table, $key, &$db = null ) {
		parent::__construct(  $table, $key, $db );
	}
예제 #5
0
	/**
	 *	Check for whether dependancies exist for this object in the db schema
	 *
	 *	@param  int      $oid   Optional key index
	 *	@return boolean         TRUE: OK to delete, FALSE: not OK to delete, error in $this->_error
	 */
	public function canDelete( $oid = null ) {
		$k = $this->_tbl_key;
		if ($oid) {
			$this->$k = $oid;
		}
		if ( $this->plan_id && ! $oid ) {
			$plan_id	=	$this->plan_id;
		} else {
			$classname	=	get_class( $this );
			$something	=	new $classname( $this->_db );
			/** @var $something cbpaidSomething */
			if ( $something->load( $this->$k ) ) {
				$plan_id	=	$something->plan_id;
			} else {
				$plan_id	=	null;
			}

		}
		if ( $plan_id ) {
			$query = "SELECT COUNT(*)"
				. "\n FROM " . $this->_db->NameQuote( $this->_tbl )
				. "\n WHERE `parent_plan` = ". (int) $plan_id
				. "\n AND `parent_subscription` = ". (int) $this->$k
			;
			$this->_db->setQuery( $query );

			$obj = null;
			$count = $this->_db->loadResult($obj);
			if ( $count > 0 ) {
				$this->setError( CBPTXT::T("Product instance still has children and can not be deleted") );
				return false;
			}
		}
		return parent::canDelete( $oid );
	}
 /**
  * Constructor
  *
  * @param  CBdatabase|null  $db
  * @param  int              $user_id
  */
 public function __construct(&$db = null, $user_id)
 {
     $this->id = (int) $user_id;
     parent::__construct('#__users', 'id', $db);
 }
예제 #7
0
	/**
	 * Constructor
	 *
	 * @param  CBdatabase  $db
	 */
	public function __construct( &$db = null ) {
		parent::__construct( '#__comprofiler_countries', 'province_iso_code', $db );
		$this->_historySetLogger();
	}
 /**
  * Constructor
  *
  * @param  CBdatabase  $db
  */
 public function __construct(&$db = null)
 {
     parent::__construct('#__cbsubs_config', 'id', $db);
     $this->_historySetLogger();
 }
	/**
	 *	Binds an array/hash from database to this object
	 *
	 *	@param  int $oid  optional argument, if not specifed then the value of current key is used
	 *	@return mixed     any result from the database operation
	 */
	public function load( $oid = null ) {
		return parent::load( $oid);
	}
	/**
	 * 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 );
	}
 /**
  * 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;
 }