/** * * @param Zend_Db_Statement_Interface $statement * @return array */ public function getLoadedValues(Zend_Db_Statement_Interface $statement) { $returningData = array(); $currentIntervallValue1 = 0; $currentIntervallValue2 = 0; $currentTimestamp = 0; $currentValue = 0.0; // First call of row. $row = $statement->fetch(); $currentTimestamp = $row['manipulationtime']; $currentValue = (double) $row['value']; $this->_setCurrentIntervallByRow($row, $currentIntervallValue1, $currentIntervallValue2); while ($row = $statement->fetch()) { if ($this->_isRowOfNewIntervall($row, $currentIntervallValue1, $currentIntervallValue2)) { $currentTimestamp = $row['manipulationtime']; $returningData[] = array($currentTimestamp, $currentValue); $currentValue = (double) $row['value']; $this->_setCurrentIntervallByRow($row, $currentIntervallValue1, $currentIntervallValue2); } else { $currentValue += (double) $row['value']; } } // TODO Fill last entry with data; doesn\'t work quite well // TODO If the last measurement is made of a new intervall, the entry will be added twice into array. // TODO Handle it if neccessary. // $returningData[] = array($currentTimestamp, $currentValue); return $returningData; }
/** * Move forward to next element */ public function next() { if (!$this->_statement instanceof \Zend_Db_Statement_Interface) { $this->_initStatement(); } $this->_row = $this->_statement->fetch(); $this->_i = $this->_i + 1; }
/** * * @param Zend_Db_Statement_Interface $statement * @return array */ public function getLoadedValues(Zend_Db_Statement_Interface $statement) { $returningData = array(); while ($row = $statement->fetch()) { $returningData[] = array($row['manipulationtime'], (double) $row['value']); } return $returningData; }
/** * @param Zend_Db_Statement_Interface $stmt * @param string $filename * @param string $title */ public function sendExcel($stmt, $filename, $title) { $this->Response()->setHeader('Content-Type', 'application/vnd.ms-excel;charset=UTF-8'); $this->Response()->setHeader('Content-Disposition', sprintf('attachment; filename="%s"', $filename)); $this->Response()->setHeader('Content-Transfer-Encoding', 'binary'); $excel = new Shopware_Components_Convert_Excel(); $excel->setTitle($title); $first = true; echo $excel->getHeader(); while ($row = $stmt->fetch()) { if ($first) { $first = false; echo $excel->encodeRow(array_keys($row)); } echo $excel->encodeRow($row); } echo $excel->getFooter(); }
/** * Migrate Entries of non-select/multiselect Entities to new Entity Table * * @param string $targetType Target Type as String * @param Zend_Db_Statement_Interface $sourceQuery Source Entity Table Query with old Entity Data to Transfer * @param string $sourceType Source Type as String * @param string $targetTable Target Entity Table * @param Varien_Db_Adapter_Interface $_dbConnection Database Connection * @param string $sourceTable Source Entity Table * @return void */ protected function _migrateNonSelect($targetType, $sourceQuery, $sourceType, $targetTable, $_dbConnection, $sourceTable) { while ($row = $sourceQuery->fetch()) { $currentValue = $row['value']; if (!is_null($currentValue)) { // Cast Value Type to new Type (e.g. decimal to text) $targetValue = $this->_typeCast($currentValue, $sourceType, $targetType); // Insert Value to target Entity $sql = 'INSERT' . ' INTO ' . $targetTable . ' (entity_type_id, attribute_id, store_id, entity_id, value) VALUES (?,?,?,?,?)'; try { $_dbConnection->query($sql, [$row['entity_type_id'], $row['attribute_id'], $row['store_id'], $row['entity_id'], $targetValue]); } catch (Exception $e) { $this->_getHelper()->log(sprintf('Exception occured while migrating Data. See exception log.'), $e); } } // Delete Value from source Entity $sql = 'DELETE' . ' FROM ' . $sourceTable . ' WHERE value_id = ?'; $_dbConnection->query($sql, $row['value_id']); } }