Resolved: [PHP-DB] Column headers
| From: | Casey Allen Shobe | Date: | Tue, 02 Jul 2002 20:39:34 +0000 |
| Subject: | Resolved: [PHP-DB] Column headers | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20279@lists.php.net to get a copy of this message | ||
On Tuesday 02 July 2002 11:18 am, Casey Allen Shobe wrote:
> Oh, and what's the difference between [int field_number] and [int
> field_offset] (from odbc_field_name and sybase_fetch_field manual pages)?
> Are they the same, or is the offset one number less than the field number,
> or is it something else entirely?
I've resolved this, thanks everyone!
// Unified query function, including row count
function db_query ($db_type, $db_query) {
// Uncomment to debug
//echo $db_query.'<br>';
if ($db_type == 'db2') {
global $db2_conn;
$result = odbc_exec ($db2_conn, $db_query);
while (odbc_fetch_into ($result, &$row)) {
$data[0][] = $row;
}
$data[1] = odbc_num_rows ($result);
for ($i = 1; $i <= odbc_num_fields ($result); $i++) {
$data[2][$i - 1] = odbc_field_name ($result, $i);
}
odbc_free_result ($result);
} else if ($db_type == 'piv') {
global $piv_conn;
$result = sybase_query ('set textsize 32768'."\n".$db_query, $piv_conn);
while ($row = sybase_fetch_array ($result)) {
$data[0][] = $row;
}
for ($i = 0; $i < sybase_num_fields ($result); $i++) {
$temp = sybase_fetch_field ($result, $i);
$data[2][$i] = $temp->name;
unset ($temp);
}
$data[1] = sybase_num_rows ($result);
}
return $data;
}
--
Casey Allen Shobe / Network Security Analyst & PHP Developer
SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144
cshobe@secureworks.net / http://www.secureworks.net
Content is my own and does not necessarily represent my company.