View Issue Details

IDProjectCategoryView StatusLast Update
0005755OXID eShop (all versions)4.01. Database handlingpublic2018-08-21 10:54
ReporterLinas Kukulskis Assigned To 
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionduplicate 
Product Version4.8.7 / 5.1.7 
Summary0005755: Fetch mode not always set to proper one
DescriptionFetch mode not always set to proper one

Steps To Reproducerequire 'bootstrap.php';
global $ADODB_FETCH_MODE;

var_dump($ADODB_FETCH_MODE);
echo PHP_EOL;

$aResult = oxDb::getDb(oxDB::FETCH_MODE_NUM)->getAll("select oxid from oxshops");
var_dump($ADODB_FETCH_MODE);

var_dump($ADODB_FETCH_MODE);
$aResult = oxDB::getDb(oxDB::FETCH_MODE_NUM)->getAll("select oxid from oxshops");
var_dump($ADODB_FETCH_MODE);

$aResult = oxDB::getDb(oxDB::FETCH_MODE_NUM)->getAll("select oxid from oxshops");
var_dump($ADODB_FETCH_MODE);

$aResult = oxDB::getDb(oxDB::FETCH_MODE_NUM)->getAll("select oxid from oxshops");
var_dump($ADODB_FETCH_MODE);
TagsNo tags attached.
ThemeMobile
BrowserAll
PHP VersionNot defined
Database VersionNot defined

Relationships

has duplicate 0006892 resolvedafshar5152 oxDB:: quoteArray & getTableDescription breaks $ADODB_FETCH_MODE 

Activities

michael_keiluweit

2017-05-10 11:57

administrator   ~0012081

Last edited: 2017-06-28 09:27

It is more or less a wheel of fortune if the custom set fetch mode is used, as some methods prefer the numeric or associative fetch mode.

The following does this (EE 5.3.4):

<?php

require_once '../bootstrap.php';

oxRegistry::getConfig()->init();
$db = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);

$r = $db->select("select oxid from oxcategories where oxid = oxrootid limit 1");
while ($r != false && !$r->EOF) {
    $catId = $r->fields['oxid'];
    var_dump($r->fields['oxid']);
    $r->moveNext();
}

$cat = oxNew('oxCategory');
$cat->load($catId);

/** @var oxSeoEncoderCategory $o */
$o = oxNew('oxSeoEncoderCategory');
$o->markRelatedAsExpired($cat);


$r = $db->select("select oxid from oxcategories where oxid = oxrootid limit 1");
while ($r != false && !$r->EOF) {
    var_dump($r->fields['oxid']);
    $r->moveNext();
}

?>

Output:

/var/www/shops/e534/bin/b5755.php:10:string '30e44ab83fdee7564.23264141' (length=26)
/var/www/shops/e534/bin/b5755.php:24:null


The method \oxSeoEncoderCategory::markRelatedAsExpired calls oxDb::getDb() which activates the fetch mode "1", which is numeric, but at the head of my script I set the fetch mode 2. So I should be able to expect to get anything with that fetch mode.

A workoround is to set oxDb::getDb(my_prefered_fetch_mode) or call $db->setFetchMode(my_prefered_fetch_mode) just before each select.

QA

2018-08-21 10:54

administrator   ~0012588

Last edited: 2018-08-21 10:54

I'll close this one. It is the original, but the entry 0006892 is more up to date.
MK