english/administrator/components/com_banners/tables/banner.php
/**
	 * method to store a row
	 *
	 * @param boolean $updateNulls True to update fields even if they are null.
	 */
method to store a row
@param boolean $updateNulls True to update fields even if they are null.
method to store a row @param boolean $updateNulls True to update fields even if they are null .
function store($updateNulls = false)
	{
		if (empty($this->id))
		{
			$purchase_type = $this->purchase_type;
			if ($purchase_type < 0 && $this->cid)
			{
				$client = JTable::getInstance('Client','BannersTable');
				$client->load($this->cid);
				$purchase_type = $client->purchase_type;
			}
			if ($purchase_type < 0)
			{
				$params = JComponentHelper::getParams('com_banners');
				$purchase_type = $params->get('purchase_type');
			}
			switch($purchase_type)
			{
			case 1:
				$this->reset='0000-00-00 00:00:00';
			break;
			case 2:
				$this->reset = JFactory::getDate('+1 year '.date('Y-m-d',strtotime('now')))->toMySQL();
			break;
			case 3:
				$this->reset = JFactory::getDate('+1 month '.date('Y-m-d',strtotime('now')))->toMySQL();
			break;
			case 4:
				$this->reset = JFactory::getDate('+7 day '.date('Y-m-d',strtotime('now')))->toMySQL();
			break;
			case 5:
				$this->reset = JFactory::getDate('+1 day '.date('Y-m-d',strtotime('now')))->toMySQL();
			break;
			}
			parent::store($updateNulls);
		}
		else
		{
			$oldrow = JTable::getInstance('Banner', 'BannersTable');
			if (!$oldrow->load($this->id) && $oldrow->getError())
			{
				$this->setError($oldrow->getError());
			}
			$table = JTable::getInstance('Banner', 'BannersTable');
			if ($table->load(array('alias'=>$this->alias,'catid'=>$this->catid)) && ($table->id != $this->id || $this->id==0)) {
				$this->setError(JText::_('COM_BANNERS_ERROR_UNIQUE_ALIAS'));
				return false;
			}
			parent::store($updateNulls);
						if ($oldrow->state>=0 && ($this->state < 0 || $oldrow->catid != $this->catid))
			{
				$this->reorder('`catid`=' . $this->_db->Quote($oldrow->catid).' AND state>=0');
			}
		}
		return count($this->getErrors())==0;
	}
function store ( $ updateNulls = false ) { if ( empty ( $ this -> id ) ) { $ purchase_type = $ this -> purchase_type ; if ( $ purchase_type < 0 && $ this -> cid ) { $ client = JTable :: getInstance ( 'Client' , 'BannersTable' ) ; $ client -> load ( $ this -> cid ) ; $ purchase_type = $ client -> purchase_type ; } if ( $ purchase_type < 0 ) { $ params = JComponentHelper :: getParams ( 'com_banners' ) ; $ purchase_type = $ params -> get ( 'purchase_type' ) ; } switch ( $ purchase_type ) { case 1 : $ this -> reset = '0000-00-00 00:00:00' ; break ; case 2 : $ this -> reset = JFactory :: getDate ( '+1 year ' . date ( 'Y-m-d' , strtotime ( 'now' ) ) ) -> toMySQL ( ) ; break ; case 3 : $ this -> reset = JFactory :: getDate ( '+1 month ' . date ( 'Y-m-d' , strtotime ( 'now' ) ) ) -> toMySQL ( ) ; break ; case 4 : $ this -> reset = JFactory :: getDate ( '+7 day ' . date ( 'Y-m-d' , strtotime ( 'now' ) ) ) -> toMySQL ( ) ; break ; case 5 : $ this -> reset = JFactory :: getDate ( '+1 day ' . date ( 'Y-m-d' , strtotime ( 'now' ) ) ) -> toMySQL ( ) ; break ; } parent :: store ( $ updateNulls ) ; } else { $ oldrow = JTable :: getInstance ( 'Banner' , 'BannersTable' ) ; if ( ! $ oldrow -> load ( $ this -> id ) && $ oldrow -> getError ( ) ) { $ this -> setError ( $ oldrow -> getError ( ) ) ; } $ table = JTable :: getInstance ( 'Banner' , 'BannersTable' ) ; if ( $ table -> load ( array ( 'alias' => $ this -> alias , 'catid' => $ this -> catid ) ) && ( $ table -> id != $ this -> id || $ this -> id == 0 ) ) { $ this -> setError ( JText :: _ ( 'COM_BANNERS_ERROR_UNIQUE_ALIAS' ) ) ; return false ; } parent :: store ( $ updateNulls ) ; if ( $ oldrow -> state >= 0 && ( $ this -> state < 0 || $ oldrow -> catid != $ this -> catid ) ) { $ this -> reorder ( '`catid`=' . $ this -> _db -> Quote ( $ oldrow -> catid ) . ' AND state>=0' ) ; } } return count ( $ this -> getErrors ( ) ) == 0 ; }
method to store a row
 @param boolean $updateNulls True to update fields even if they are null.
method to store a row @param boolean $updateNulls True to update fields even if they are null .
// Store the row // Get the old row // Verify that the alias is unique // Store the new row // Need to reorder ?
 // Reorder the oldrow