/**
  * (non-PHPdoc)
  * @see DataObject\Factory::_update()
  */
 protected function _update($mId, array $aData)
 {
     if (!$this->isLocaleSet()) {
         throw new Exception('Language is not set');
     }
     $sFieldName = '_' . $this->_sTableName;
     if (!empty($aData[$sFieldName])) {
         try {
             $oUpdate = (new Update($this->_sTableName))->set($aData[$sFieldName])->where([$this->_sPrimaryKey => $mId, 'locale' => $this->getLocale()]);
             $oDb = Factory::getConnection();
             $oDb->query((new Sql($oDb))->getSqlStringForSqlObject($oUpdate), $oDb::QUERY_MODE_EXECUTE);
         } catch (\Exception $e) {
             throw new Exception('Error while updating data', null, $e);
         }
         unset($aData[$sFieldName]);
     }
     parent::_update($mId, $aData);
 }
Esempio n. 2
0
 /**
  * Private update method
  *
  * @param	mixed	$mId	primary value
  * @param	array	$aData	data to update
  * @throws	Exception
  * @return	void
  */
 protected function _update($mId, array $aData)
 {
     if (empty($aData)) {
         return;
     }
     try {
         $oUpdate = (new Update($this->sTableName))->set($aData)->where($this->getPrimaryWhere($mId));
         // wykonuje zapytanie
         $oDb = Factory::getConnection();
         $oDb->query((new Sql($oDb))->getSqlStringForSqlObject($oUpdate), $oDb::QUERY_MODE_EXECUTE);
     } catch (\Exception $e) {
         throw new Exception('Error while updating data', null, $e);
     }
 }
Esempio n. 3
0
 public function onBootstrap(MvcEvent $oEvent)
 {
     Factory::setConnection($oEvent->getApplication()->getServiceManager()->get('Application\\Db'));
 }
Esempio n. 4
0
 /**
  * Return an array of elements on a selected page
  *
  * @param	int		$iOffset		query offset
  * @param	int		$iItemsPerPage	items limit per page
  * @return	array
  */
 public function getItems($iOffset, $iItemsPerPage)
 {
     $iPage = floor($iOffset / $iItemsPerPage) + 1;
     return $this->oFactory->getPage($iPage, $iItemsPerPage, $this->aOrder, $this->oWhere, $this->mOption);
 }
 /**
  * Extends select for aggregation
  *
  * @param	Select	$oSelect	actual select
  * @param	string	$sPrimary	primary field name (with table name!)
  * @param	string	$sType		JOIN type
  * @return	Select
  */
 public function aggregateGetSelect(Select $oSelect, $sPrimary, $sType = Select::JOIN_INNER)
 {
     $oPrimary = new Expression(Factory::getConnection()->getPlatform()->quoteIdentifierChain(explode('.', $sPrimary)));
     return $oSelect->join($this->getTableName(), $this->getPrimaryWhere($oPrimary), $this->multitablePrefixAdd($this->getTableName(), $this->getTableFields()), $sType);
 }