function db_fetch_array($rs, $assoc = 1) { global $mssql_dmy; if ($rs->EOF()) { return false; } try { $ret = array(); for ($i = 0; $i < db_numfields($rs); $i++) { if (IsBinaryType($rs->Fields[$i]->Type) && $rs->Fields[$i]->Type != 128) { $str = ""; if ($rs->Fields[$i]->ActualSize) { $val = $rs->Fields[$i]->GetChunk($rs->Fields[$i]->ActualSize); $str = str_pad("", count($val)); $j = 0; foreach ($val as $byte) { $str[$j++] = chr($byte); } } if ($assoc) { $ret[$rs->Fields[$i]->Name] = $str; } else { $ret[$i] = $str; } } else { $value = $rs->Fields[$i]->Value; if (is_null($value)) { $val = NULL; } else { if (isdatefieldtype($rs->Fields[$i]->Type)) { $value = localdatetime2db((string) $rs->Fields[$i]->Value, $mssql_dmy); } if (IsNumberType($rs->Fields[$i]->Type)) { $val = floatval($value); } else { $val = strval($value); } } if ($assoc) { $ret[$rs->Fields[$i]->Name] = $val; } else { $ret[$i] = $val; } } } $rs->MoveNext(); } catch (com_exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); } return $ret; }
/** * Fetch a result row as an array * @param Mixed qHanle The query handle * @param Number assoc (optional) * @return Array */ protected function _fetch_array($qHanle, $assoc = 1) { $ret = array(); if ($qHanle->EOF()) { return false; } try { for ($i = 0; $i < $this->num_fields($qHanle); $i++) { if (IsBinaryType($qHanle->Fields[$i]->Type) && $qHanle->Fields[$i]->Type != 128 || $qHanle->Fields[$i]->Type == 203) { $str = ""; if ($qHanle->Fields[$i]->ActualSize > 0) { $size = $qHanle->Fields[$i]->ActualSize; $val = $qHanle->Fields[$i]->GetChunk($size); if (is_array($val) || is_object($val)) { $str = str_pad("", $size); $j = 0; foreach ($val as $byte) { $str[$j++] = chr($byte); } } else { $str = $val; } } if ($assoc) { $ret[$qHanle->Fields[$i]->Name] = $str; } else { $ret[$i] = $str; } } else { $value = $qHanle->Fields[$i]->Value; if (is_null($value)) { $val = NULL; } else { if (isdatefieldtype($qHanle->Fields[$i]->Type)) { $value = localdatetime2db((string) $qHanle->Fields[$i]->Value, $this->access_dmy); } if (IsNumberType($qHanle->Fields[$i]->Type)) { $val = floatval($value); } else { $val = strval($value); } } if ($assoc) { $ret[$qHanle->Fields[$i]->Name] = $val; } else { $ret[$i] = $val; } } } $qHanle->MoveNext(); } catch (com_exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); } return $ret; }