Home » Database » MDB2 » Bug #5508
Compatibility Level for MDB2_FETCHMODE_ASSOC
Details
| Request #5508 | Compatibility Level for MDB2_FETCHMODE_ASSOC |
|---|---|
| Submitted | 2005-09-24 14:05 UTC |
| From | lowtzow at gmx dot de |
| Status | Wont fix |
| Package | MDB2 |
| PHP Version | 5.0.4 |
| OS | Windows XP |
| Roadmaps | (Not assigned) |
Comments
[2005-09-24 14:05 UTC] lowtzow at gmx dot de
Description:
------------
Would like to have a compatibility level
for MDB2_FETCHMODE_ASSOC with computed columns.
The column name for "avg(...)" is in MySQL "avg(...)",
but in MSSql it is "computed".
(An other problem is that MSSQL computes avg of an integer column as an integer, MySQL or SQLite as a float.)
Test script:
---------------
<?php
require_once 'MDB2.php';
//$dsn = "sqlite:///c:/temp/egon.db";
//$dsn = "mysql://root:@localhost/test";
$dsn = "mssql://BALDUIN/Bachelor";
$db =& MDB2::connect($dsn);
$db->setFetchMode(MDB2_FETCHMODE_ASSOC);
$res = $db->query('create table avgtest ('.
'eins integer primary key, zwei integer null)');
$res =& $db->query(
"INSERT INTO avgtest (eins,zwei) VALUES (1, 3)");
$res =& $db->query(
"INSERT INTO avgtest (eins,zwei) VALUES (2, 4)");
$sql = 'Select count(zwei), avg(zwei) from avgtest';
$row = $db->queryRow($sql);
echo "<pre>";
print_r($row);
echo "</pre>";
?>
Expected result:
----------------
Array
(
[count(zwei)] => 2
[avg(zwei)] => 3.5
)
Actual result:
--------------
Array
(
[computed] => 2
[computed1] => 3
)