note 108330 added to function.odbc-result
| From: | cgray at develop4 dot us | Date: | Tue, 17 Apr 2012 21:10:05 +0000 |
| Subject: | note 108330 added to function.odbc-result | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187210@lists.php.net to get a copy of this message | ||
FYI: odbc_result contains the following values:
TABLE_QUALIFIER TABLE_OWNER TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME PRECISION LENGTH SCALE RADIX NULLABLE REMARKS COLUMN_FLAGS
I wrote the following to dump these values onto the page. I needed this to determine if the
data-type for a column was something specific (eg: blob) to show a different result, instead of the
actual contents.
$connection_string = 'OPTIM_BLOB';
$user = '';
$pass = '';
if (!($connect = odbc_pconnect($connection_string, $user, $pass))) {
} else {
echo 'Connecting to DSN, loading tables<br /><br />';
$result = odbc_tables($myconn);
$tables = array();
while (odbc_fetch_row($result)){
if(odbc_result($result,"TABLE_TYPE")=="TABLE") {
$TableName = odbc_result($result,"TABLE_NAME");
echo '<span id="tableName">Table: '.$TableName.'</span>
....<br /><br /> ';
//--------- Show Columns in that table ---------------
$result2 = odbc_columns($myconn, '', "%", $TableName, "%"); //db
connection, DB name, schema, table name, column_name);
while(odbc_fetch_row($result2)){
//TABLE_QUALIFIER TABLE_OWNER TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME PRECISION LENGTH SCALE RADIX NULLABLE REMARKS COLUMN_FLAGS
$COLUMN_NAME = odbc_result($result2, 4); // COLUMN_NAME
$DataType = odbc_result($result2, 6);
echo '<b>Column name: '.$COLUMN_NAME.'</b> Type:
'.$DataType.'<br /><br />';
// everything
echo '1: '.odbc_result($result2, 1).'<br />'; // TABLE_QUALIFIER
echo '2: '.odbc_result($result2, 2).'<br />'; // TABLE_OWNER
echo '3: '.odbc_result($result2, 3).'<br />'; // TABLE_NAME
echo '4: '.odbc_result($result2, 4).'<br />'; // COLUMN_NAME
echo '5: '.odbc_result($result2, 5).'<br />'; // DATA_TYPE (Number)
echo '6: '.odbc_result($result2, 6).'<br />'; // TYPE_NAME (String)
echo '7: '.odbc_result($result2, 7).'<br />'; // PRECISION
echo '8: '.odbc_result($result2, 8).'<br />'; // LENGTH
echo '9: '.odbc_result($result2, 9).'<br />'; // SCALE
echo '10: '.odbc_result($result2, 10).'<br />'; // RADIX
echo '11: '.odbc_result($result2, 11).'<br />'; // NULLABLE
echo '12: '.odbc_result($result2, 12).'<br />'; // REMARKS
echo '13: '.odbc_result($result2, 13).'<br />'; // COLUMN_FLAGS
echo '<br /><br />';
}
}
}
}
----
Server IP: 69.147.83.197
Probable Submitter: 96.57.157.114
----
Manual Page -- http://www.php.net/manual/en/function.odbc-result.php
Edit -- https://master.php.net/note/edit/108330
Del: integrated -- https://master.php.net/note/delete/108330/integrated
Del: useless -- https://master.php.net/note/delete/108330/useless
Del: bad code -- https://master.php.net/note/delete/108330/bad+code
Del: spam -- https://master.php.net/note/delete/108330/spam
Del: non-english -- https://master.php.net/note/delete/108330/non-english
Del: in docs -- https://master.php.net/note/delete/108330/in+docs
Del: other reasons-- https://master.php.net/note/delete/108330
Reject -- https://master.php.net/note/reject/108330
Search -- https://master.php.net/manage/user-notes.php