Beispiel #1
0
 public function addConfigField($path, $label, array $data = array(), $default = null)
 {
     $data['level'] = sizeof(explode('/', $path));
     $data['path'] = $path;
     $data['frontend_label'] = $label;
     if ($id = $this->getTableRow('core/config_field', 'path', $path, 'field_id')) {
         $this->updateTableRow('core/config_field', 'field_id', $id, $data);
     } else {
         if (empty($data['sort_order'])) {
             $sql = "select max(sort_order) cnt from " . $this->getTable('core/config_field') . " where level=" . ($data['level'] + 1);
             if ($data['level'] > 1) {
                 $sql .= $this->_conn->quoteInto(" and path like ?", dirname($path) . '/%');
             }
             $result = $this->_conn->raw_fetchRow($sql);
             $this->_conn->fetchAll($sql);
             #print_r($result); die;
             $data['sort_order'] = $result['cnt'] + 1;
             /*
             // Triggers "Command out of sync" mysql error for next statement!?!?
                             $data['sort_order'] = $this->_conn->fetchOne("select max(sort_order)
                                 from ".$this->getTable('core/config_field')."
                                 where level=?".$parentWhere, $data['level'])+1;
             */
         }
         #$this->_conn->raw_query("insert into ".$this->getTable('core/config_field')." (".join(',', array_keys($data)).") values ('".join("','", array_values($data))."')");
         $this->_conn->insert($this->getTable('core/config_field'), $data);
     }
     if (!is_null($default)) {
         $this->setConfigData($path, $default);
     }
     return $this;
 }
Beispiel #2
0
 public function getTableDataDump($tableName, $step = 100)
 {
     $sql = '';
     if ($this->_read) {
         $quotedTableName = $this->_read->quoteIdentifier($tableName);
         $colunms = $this->_read->fetchRow('SELECT * FROM ' . $quotedTableName . ' LIMIT 1');
         if ($colunms) {
             $arrSql = array();
             $colunms = array_keys($colunms);
             $quote = $this->_read->getQuoteIdentifierSymbol();
             $sql = 'INSERT INTO ' . $quotedTableName . ' (' . $quote . implode($quote . ', ' . $quote, $colunms) . $quote . ')';
             $sql .= ' VALUES ';
             $startRow = 0;
             $select = $this->_read->select();
             $select->from($tableName)->limit($step, $startRow);
             while ($data = $this->_read->fetchAll($select)) {
                 $dataSql = array();
                 foreach ($data as $row) {
                     $dataSql[] = $this->_read->quoteInto('(?)', $row);
                 }
                 $arrSql[] = $sql . implode(', ', $dataSql) . ';';
                 $startRow += $step;
                 $select->limit($step, $startRow);
             }
             $sql = implode("\n", $arrSql) . "\n";
         }
     }
     return $sql;
 }
Beispiel #3
0
 /**
  * Load settings for the specified scope.
  *
  * @param $websiteId
  * @param $storeId
  * @return Itoris_LayeredNavigation_Model_Settings
  */
 public function load($websiteId, $storeId)
 {
     $websiteId = (int) $websiteId;
     $storeId = (int) $storeId;
     $settings = $this->_resource->fetchAll("SELECT e.key, e.scope,e.int_value, e.text_value, e.type\n\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->_table} as e\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE (e.scope = 'default' and e.scope_id = 0)\n\t\t\t\t\t\t\t\t\t\t\t\tOR (e.scope = 'website' and e.scope_id = {$websiteId})\n\t\t\t\t\t\t\t\t\t\t\t\tOR (e.scope = 'store' and e.scope_id = {$storeId})");
     $this->_saveSettingsIntoArray($settings);
     return $this;
 }
 public function load($websiteId, $storeId)
 {
     $websiteId = (int) $websiteId;
     $storeId = (int) $storeId;
     $settings = $this->_connection->fetchAll("\n\t\t\tselect e.* from {$this->_table} as e\n\t\t\twhere (e.website_id = {$websiteId} and e.store_id = {$storeId})\n\t\t\t\t\tor (e.website_id = {$websiteId} and e.store_id = 0)\n\t\t\t\t\tor (e.website_id = 0 and e.store_id = 0)\n\t\t");
     foreach ($settings as $setting) {
         $settingValue = $this->_isTextOption($setting['code']) ? $setting['value_text'] : $setting['value'];
         if ($setting['website_id'] && $setting['store_id']) {
             $this->_settings['store'][$setting['code']] = $settingValue;
         } elseif ($setting['website_id']) {
             $this->_settings['website'][$setting['code']] = $settingValue;
         } else {
             $this->_settings['default'][$setting['code']] = $settingValue;
         }
     }
     return $this;
 }
Beispiel #5
0
 /**
  * Returns whether table exists
  *
  * @param string $table
  * @return bool
  */
 protected function _tableExists($table)
 {
     $rows = $this->_adapter->fetchAll('SHOW TABLES');
     foreach ($rows as $row) {
         $tableFound = strtolower(current($row));
         if ($table == $tableFound) {
             return true;
         }
     }
     return false;
 }
 protected function getLikeExistItem($newItem, $ignoreTitle = true, $attributeSet = NULL)
 {
     $whereSql = '';
     foreach ($newItem as $key => $value) {
         if ($ignoreTitle && $key == 'title') {
             continue;
         }
         if ($whereSql == '') {
             $whereSql .= ' ';
         } else {
             $whereSql .= ' AND ';
         }
         $whereSql .= ' `' . $key . '` ';
         is_null($value) && ($whereSql .= ' IS NULL ');
         is_string($value) && ($whereSql .= ' = ' . $this->mySqlReadConnection->quote($value) . ' ');
         (is_integer($value) || is_float($value)) && ($whereSql .= ' = ' . $value . ' ');
     }
     $dbSelect = $this->mySqlReadConnection->select()->from($this->tableNameNew, '*');
     $whereSql != '' && $dbSelect->where($whereSql);
     $row = $this->mySqlReadConnection->fetchRow($dbSelect);
     if ($row === false) {
         return NULL;
     }
     if (!is_null($attributeSet)) {
         $templateId = (int) $row['id'];
         $templateType = (int) $attributeSet['template_type'];
         $attributeSetId = (int) $attributeSet['attribute_set_id'];
         $tasTable = Mage::getResourceModel('M2ePro/TemplatesAttributeSets')->getMainTable();
         $dbSelect = $this->mySqlReadConnection->select()->from($tasTable, '*')->where('template_type = ?', $templateType)->where('template_id = ?', $templateId);
         $rowsAttributesSets = $this->mySqlReadConnection->fetchAll($dbSelect);
         if ($rowsAttributesSets === false || count($rowsAttributesSets) != 1) {
             return NULL;
         }
         $rowAttributeSet = $rowsAttributesSets[0];
         if ((int) $rowAttributeSet['attribute_set_id'] != $attributeSetId) {
             return NULL;
         }
     }
     return $row;
 }
Beispiel #7
0
 public function getValues($type)
 {
     $dbSelect = $this->mySqlReadConnection->select()->from($this->tableName, '*')->where('`type` = ?', (string) $type);
     return $this->mySqlReadConnection->fetchAll($dbSelect);
 }
 /**
  * Generate Cron Status Information
  *
  * @return array
  * @throws Exception
  */
 protected function _generateCronStatusData()
 {
     $systemReport = array();
     if (!$this->_readConnection) {
         throw new Exception('Cant\'t connect to DB. Cron schedule status can\'t be retrieved.');
     }
     // Cron status by status code
     $data = array();
     try {
         $info = $this->_readConnection->fetchAll("\n                SELECT COUNT( * ) AS `cnt` , `status`\n                FROM `{$this->_getTableName('cron/schedule')}`\n                GROUP BY `status`\n                ORDER BY `status`\n            ");
         if ($info) {
             foreach ($info as $_data) {
                 $data[] = array($_data['status'], $_data['cnt']);
             }
         }
         $systemReport['Cron Schedules by status code'] = array('header' => array('Status Code', 'Count'), 'data' => $data);
     } catch (Exception $e) {
         $this->_log($e);
     }
     // Cron status by job code
     $data = array();
     try {
         $info = $this->_readConnection->fetchAll("\n                SELECT COUNT( * ) AS `cnt` , `job_code`\n                FROM `{$this->_getTableName('cron/schedule')}`\n                GROUP BY `job_code`\n                ORDER BY `job_code`\n            ");
         if ($info) {
             foreach ($info as $_data) {
                 $data[] = array($_data['job_code'], $_data['cnt']);
             }
         }
         $systemReport['Cron Schedules by job code'] = array('header' => array('Job Code', 'Count'), 'data' => $data);
     } catch (Exception $e) {
         $this->_log($e);
     }
     return $systemReport;
 }