Ejemplo n.º 1
0
 /**
  * Test that column names are quoted in ON DUPLICATE KEY UPDATE section
  */
 public function testInsertOnDuplicateWithQuotedColumnName()
 {
     $table = 'some_table';
     $data = ['index' => 'indexValue', 'row' => 'rowValue', 'select' => 'selectValue', 'insert' => 'insertValue'];
     $fields = ['select', 'insert'];
     $sqlQuery = "INSERT INTO `some_table` (`index`,`row`,`select`,`insert`) VALUES (?, ?, ?, ?) " . "ON DUPLICATE KEY UPDATE `select` = VALUES(`select`), `insert` = VALUES(`insert`)";
     $stmtMock = $this->getMock('Zend_Db_Statement_Pdo', [], [], '', false);
     $bind = ['indexValue', 'rowValue', 'selectValue', 'insertValue'];
     $this->_adapter->expects($this->once())->method('query')->with($sqlQuery, $bind)->will($this->returnValue($stmtMock));
     $this->_adapter->insertOnDuplicate($table, $data, $fields);
 }
Ejemplo n.º 2
0
 /**
  *  Collected link data insertion.
  *
  * @return $this
  * @throws \Zend_Db_Exception
  */
 protected function _insertData()
 {
     $mainTable = $this->_resource->getTableName('catalog_product_super_attribute');
     $labelTable = $this->_resource->getTableName('catalog_product_super_attribute_label');
     $priceTable = $this->_resource->getTableName('catalog_product_super_attribute_pricing');
     $linkTable = $this->_resource->getTableName('catalog_product_super_link');
     $relationTable = $this->_resource->getTableName('catalog_product_relation');
     $mainData = [];
     foreach ($this->_superAttributesData['attributes'] as $productId => $attributesData) {
         foreach ($attributesData as $attrId => $row) {
             $row['product_id'] = $productId;
             $row['attribute_id'] = $attrId;
             $mainData[] = $row;
         }
     }
     if ($mainData) {
         $this->_connection->insertOnDuplicate($mainTable, $mainData);
     }
     if ($this->_superAttributesData['labels']) {
         $this->_connection->insertOnDuplicate($labelTable, $this->_superAttributesData['labels']);
     }
     if ($this->_superAttributesData['pricing']) {
         $this->_connection->insertOnDuplicate($priceTable, $this->_superAttributesData['pricing'], ['is_percent', 'pricing_value']);
     }
     if ($this->_superAttributesData['super_link']) {
         $this->_connection->insertOnDuplicate($linkTable, $this->_superAttributesData['super_link']);
     }
     if ($this->_superAttributesData['relation']) {
         $this->_connection->insertOnDuplicate($relationTable, $this->_superAttributesData['relation']);
     }
     return $this;
 }