/** * @dataProvider insertDataProvider */ public function testInsertForce($data) { $this->assertEquals(1, $this->_connection->insertForce($this->_tableName, $data)); $select = $this->_connection->select()->from($this->_tableName); $result = $this->_connection->fetchRow($select); $this->assertEquals($data, $result); }
/** * Assert that session data writes to DB in base64 encoding */ public function testWriteEncoded() { $data = serialize($this->_sessionData[self::SESSION_NEW]); $this->_model->write(self::SESSION_ID, $data); $select = $this->_connection->select()->from($this->_sessionTable)->where(self::COLUMN_SESSION_ID . ' = :' . self::COLUMN_SESSION_ID); $bind = array(self::COLUMN_SESSION_ID => self::SESSION_ID); $session = $this->_connection->fetchRow($select, $bind); $this->assertEquals(self::SESSION_ID, $session[self::COLUMN_SESSION_ID]); $this->assertTrue(ctype_digit((string) $session[self::COLUMN_SESSION_EXPIRES]), 'Value of session expire field must have integer type'); $this->assertEquals($data, base64_decode($session[self::COLUMN_SESSION_DATA])); }
/** * Check unique url_key value in catalog_category_entity_url_key table. * * @param Mage_Catalog_Model_Abstract $object * @return bool * @throws Mage_Core_Exception */ protected function _isAvailableUrl($object) { $select = $this->_connection->select()->from($this->getAttribute()->getBackendTable(), array('entity_id', 'store_id'))->where('value = ?', $object->getUrlKey())->limit(1); $row = $this->_connection->fetchRow($select); // we should allow save same url key for product in current store view // but not allow save existing url key in current store view from another store view if (empty($row)) { return true; } elseif ($object->getId() && $object->getStoreId() !== null && ($row['store_id'] == $object->getStoreId() && $row['entity_id'] == $object->getId())) { return true; } return false; }
/** * Retrieve category instance by specified parameters * * @param Mage_Core_Model_Resource $resource * @param array $row * @return int */ function getCategoryId($resource, $row) { $select = $this->_connection->select()->from(array('nur' => $resource->getTableName('enterprise_url_rewrite')))->join(array('e' => $resource->getTableName(array('catalog/category', 'url_key'))), 'nur.value_id = e.value_id')->where('nur.url_rewrite_id = ' . $row['url_rewrite_id']); $entityRow = $this->_connection->fetchRow($select); return $entityRow['entity_id']; }