View Issue Details

IDProjectCategoryView StatusLast Update
0006976OXID eShop (all versions)4.01. Database handlingpublic2019-05-03 13:43
Reporterleofonic 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version6.1.3 
Target VersionFixed in Version 
Summary0006976: Database methods like "getAll" do not work sometimes
DescriptionIn class database there is a wrapper for methods getOne and getAll. There is a check whether the statement is a select query that has an output or an action which has no output. This check, method "doesStatementProduceOutput", looks for the first word in the statement. If the statement is a union statement that begins with a bracket, the first word is recognized as "(SELECT", which is not in the list of known words, therefore the return of "getAll" is an empty array.
Steps To ReproduceUse "getAll" in a module with a select statement with "union" and starting with a bracket.
TagsNo tags attached.
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
MySQL VersionNot defined

Activities

QA

2019-05-03 13:43

administrator   ~0012878

$db = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
$result = $db->getAll('(select oxtitle from oxarticles limit 2) union (select oxtitle from oxcategories limit 2)');
var_dump($result);

Results in:
/var/www/html/source/index.php:13:
array (size=0)
  empty


Expected an array with values like this:
MySQL [oxid]> (select oxtitle from oxarticles limit 2) union (select oxtitle from oxcategories limit 2);
+---------------------+
| oxtitle             |
+---------------------+
|                     |
| Trapez ION MADTRIXX |
| Bindungen           |
| Trapeze             |
+---------------------+
4 rows in set (0.00 sec)

MySQL [oxid]>


-MK