View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0005755 | OXID eShop (all versions) | 4.01. Database handling | public | 2014-05-09 13:19 | 2018-08-21 10:54 |
Reporter | Linas Kukulskis | Assigned To | |||
Priority | high | Severity | major | Reproducibility | always |
Status | closed | Resolution | duplicate | ||
Product Version | 4.8.7 / 5.1.7 | ||||
Summary | 0005755: Fetch mode not always set to proper one | ||||
Description | Fetch mode not always set to proper one | ||||
Steps To Reproduce | require '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); | ||||
Tags | No tags attached. | ||||
Theme | Mobile | ||||
Browser | All | ||||
PHP Version | Not defined | ||||
Database Version | Not defined | ||||
has duplicate | 0006892 | resolved | afshar5152 | oxDB:: quoteArray & getTableDescription breaks $ADODB_FETCH_MODE |
|
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. |
|
I'll close this one. It is the original, but the entry 0006892 is more up to date. MK |