Exemplo n.º 1
0
 /**
  * Returns the total number of records in the query
  *
  * @return	int
  */
 public function count()
 {
     if ($this->iCount === null) {
         $aDbRes = (new Sql(Factory::getConnection()))->prepareStatementForSqlObject($this->oCountSelect)->execute()->current();
         $this->iCount = array_shift($aDbRes);
     }
     return $this->iCount;
 }
 /**
  * (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);
 }
Exemplo n.º 3
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);
     }
 }
 /**
  * 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);
 }