 |
odbc_columns (PHP 4, PHP 5) odbc_columns --
Lists the column names in specified tables
Descriptionresource odbc_columns ( resource connection_id [, string qualifier [, string schema [, string table_name [, string column_name]]]] )
Lists all columns in the requested range. Returns an ODBC result
identifier containing the information or FALSE on failure.
The result set has the following columns:
TABLE_QUALIFIER TABLE_SCHEM TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME PRECISION LENGTH SCALE RADIX NULLABLE REMARKS
The result set is ordered by TABLE_QUALIFIER, TABLE_SCHEM and
TABLE_NAME.
The schema,
table_name and
column_name arguments accept search
patterns ('%' to match zero or more characters and '_' to match a
single character).
See also odbc_columnprivileges() to retrieve
associated privileges.
ke3wh at comcast dot net
26-Nov-2004 09:47
The complete script to get into from a DSN MS Access DB Table and display it is below.
function Error_Handler( $msg, $cnx ) {
echo "$msg \n";
odbc_close( $cnx);
exit();
}
$cnx = odbc_connect( 'DSN_NAME' , '', '' );//connect to MSAccess
if (!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
$res400= odbc_columns($cnx,"DSN_NAME","","TABLE");
echo odbc_result_all($res400);
laundro at gmail dot com
16-Nov-2004 12:29
Getting all column names from Excel with ODBC:
$cols = odbc_columns($connection, $filename, NULL, $sheet);
where:
$connection is the result of your odbc_connect;
$filename is the filename of the Excel file;
$sheet is the name of the Excel worksheet.
This is useful when you want to query an Excel file without having to name ranges beforehand. With the results obtained from the above command, you can populate an array and use its contents (ie the column names) for further querying.
netaminas at hotamil dot com
26-Feb-2004 06:21
Connect with IBM Client Access 32-bit ODBC driver
To access table information in DB2 iSeries (AS/400) via ODBC Driver i've tried with this code and worked!!!
$conn_ODBC = odbc_connect("DSN", "USER", "PASSW") or die;
$tabela = "table name in IBM iSeries";
$libname = "library name in IBM iSeries"
$res400 = odbc_columns($conn_ODBC, "DSN", $libname, $tabela, "%") or die("<p><font color=#FF0000>Erro Na Leitura da Tabela ".$tabela." do AS/400: ".odbc_errormsg());
echo odbc_result_all($res400);
Netaminas.com
PORTUGAL
Sergio Sartori
26-Feb-2003 12:05
Using this function on a MS SQL Server 2000 database connection with the syntax:
$res = odbc_columns($connId, $dbName, "%", $tableName, "%");
I actually get a result set with THESE columns name:
TABLE_CAT, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, DATA_TYPE, TYPE_NAME, COLUMN_SIZE, BUFFER_LENGTH, DECIMAL_DIGITS, NUM_PREC_RADIX, NULLABLE, REMARKS
in the order displayed.
josh at engledental dot com
13-Jun-2002 08:34
(PHP4.2.1, Win2k, MSSQL 2K)
The result id returned from this function does not appear to behave exactly the same as a result id returned from a query.
I get all sorts of errors when I try to use subsequent odbc functions on the result id, such as:
odbc_fetch_into - This function only seems to work if I don't specify a row number or if the row number = 0.
odbc_fetch_row - This function will not return a row from the result set. Under some scenarios, I am able to use it in a while loop, but its seems buggy. Hence, my odbc_num_of_rows function (hack to replace the non-functional odbc_num_rows function) also doesn't work.
I recommend dumping the results into an array immediately and freeing the result id created by this function.
ps - If anyone has any further insight or workarounds, I would appreciate them.
LyleE at LocalMotion dot com
23-Feb-2001 03:53
Took me a while to figure out this command, thought I would save some other people the time. We couldn't quite figure out what the qualifier was. For MSSQL 7.0, it is the Database that you are connecing to. For the pubs database it would look something like this.
$rs = odbc_columns($DBConnection, "Pubs", "%", "jobs");
That would be for showing the jobs table.
fmk at swwwing dot com
03-Oct-2000 03:23
Before PHP 4.0.3 uou could use this function with 1 or 5 prarms. From 4.0.3 the function matches the documentation.
|  |