Home » Database » MDB » Bug #3144
Additional fetchmode for better oracle compatibility
Details
| Request #3144 | Additional fetchmode for better oracle compatibility |
|---|---|
| Submitted | 2005-01-09 13:31 UTC |
| From | buhmann at teqneers dot de |
| Status | Bogus |
| Package | MDB |
| PHP Version | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-01-09 13:31 UTC] buhmann at teqneers dot de
Description:
------------
The existing MDB_FETCHMODE_FLIPPED results in an equal way like ocifetchstatement() by using MDB::fetchAll(). But in the native oci functions, it's possible to get also an assoc array instead of a numbered array in flipped mode.
e.g.:
MDB:
array(
'0' => array( '0'=>'rowx1', '1'=>'rowx2' ),
'1' => array( '0'=>'rowy1', '1'=>'rowy2' )
)
OCI
array(
'colname1' => array( '0'=>'rowx1', '1'=>'rowx2' ),
'colname2' => array( '0'=>'rowy1', '1'=>'rowy2' )
)
So it could be very helpful to add an additional fetch mode (e.g. MDB_FETCHMODE_ASSOC_FLIPPED) to get the same result.
A possible way for implementing is to change the Common.php fetchAll() method:
...
$all = array();
while (is_array($row = $this->fetchInto($result, $fetchmode))) {
...
to
...
if ( $fetchmode & MDB_FETCHMODE_ASSOC_FLIPPED ) {
$fetchmode_into = MDB_FETCHMODE_ASSOC;
$fetchmode = MDB_FETCHMODE_FLIPPED;
}else{
$fetchmode_into = $fetchmode;
}
$all = array();
while (is_array($row = $this->fetchInto($result, $fetchmode_into))) {
...
[2005-01-09 13:59 UTC] smith at backendmedia dot com
Have you tried to pass the following fetchmode to the fetchAll() method?
$fetchmode = MDB_FETCHMODE_ASSOC + MDB_FETCHMODE_FLIPPED;
[2005-01-09 14:15 UTC] buhmann at teqneers dot de
thanks, that's working. (MDB_FETCHMODE_ASSOC + MDB_FETCHMODE_FLIPPED)
[2005-01-09 17:31 UTC] smith at backendmedia dot com
Actually probably the following would be cleaner (thx daniel for pointing this out to me):
$fetchmode = MDB_FETCHMODE_ASSOC | MDB_FETCHMODE_FLIPPED;