Home » Database » DB » Bug #231
sybase fetchInto() returns incompatible data
Details
| Submitted | 2003-11-12 19:23 UTC |
|---|---|
| From | tpg at umich dot edu |
| Status | Duplicate |
| Package | DB |
| PHP Version | 4.3.3 |
| OS | Solaris/Linux |
| Roadmaps | (Not assigned) |
Comments
[2003-11-12 19:23 UTC] tpg at umich dot edu
Description:
------------
Sybase and mysql do not agree on the array being returned.
Mysql returns a clean associative array.
Sybase returns the same AND elements with numeric keys.
So if the idea is this is supposed to present something
transparent, then we must coerce the Sybase data to look
like Mysql. Perhaps Mysql is the odd ball, but the lowest
common denominator wins :-( or this needs to be documented
so dummies like me know what is going on
I've been using this fix in DB 1.3, 1.4 and now 1.5
function fetchInto($result, &$ar, $fetchmode, $rownum=null)
{
if ($rownum !== null) {
if (!@sybase_data_seek($result, $rownum)) {
return null;
}
}
//$ar = ($fetchmode & DB_FETCHMODE_ASSOC) ? @sybase_fetch_array($result) : @sybase_fetch_row($result);
$arr = ($fetchmode & DB_FETCHMODE_ASSOC) ? @sybase_fetch_array($result) : @sybase_fetch_row($result);
if (!$ar) {
// reported not work as seems that sybase_get_last_message()
// always return a message here
//if ($errmsg = sybase_get_last_message()) {
// return $this->sybaseRaiseError($errmsg);
//} else {
return null;
//}
}
// Sybase and mysql do not agree on the array being returned.
// Mysql returns a clean associative array.
// Sybase returns the same AND elements with numeric keys.
// So if the idea is this is supposed to present something
// transparent, then we must coerce the Sybase data to look
// like Mysql. Perhaps Mysql is the odd ball, but the lowest
// common denominator wins :-( or this needs to be documented
// so dummies like me know what is going on
$ar = array();
$i=0;
while (list($col,$val) = each($arr)) {
if ($col == $i) { $i++; }
else { $ar[$col] = $val; }
}
return DB_OK;
}