Set WeberTrivia.com to be my default homepage.   Suggest a Question                                               

Suggest A Question : :  Frequently Asked Questions : :  Search : :  Relevant Manuals : : 
PHP Questions : :  Linux Questions : :  MySQL Questions : : 
home  [ Login ] 

DB_common::tableInfo()

DB_common::tableInfo() -- Get info about columns in a table or a query result

Description

Get information about columns in a table or a query result.

Parameter

mixed $result

DB_result object from a query or a string containing the name of a table

This can also be a query result resource identifier, but doing so is deprecated.

integer $mode

one of the tableInfo mode constants

Return value

Returns an associative array of column information. DB_Error object if problems arise.

The array's contents depends on the mode parameter.

tableInfo Modes

This section describes the format of the returned array and how it varies depending on which mode was used when the function was called.

The sample output below is based on this query:

SELECT tblFoo.fldID, tblFoo.fldPhone, tblBar.fldId     FROM tblFoo     JOIN tblBar ON tblFoo.fldId = tblBar.fldId;

NULL or 0

[0] => Array (     [table] => tblFoo     [name] => fldId     [type] => int     [len] => 11     [flags] => primary_key not_null ) [1] => Array (     [table] => tblFoo     [name] => fldPhone     [type] => string     [len] => 20     [flags] => ) [2] => Array (     [table] => tblBar     [name] => fldId     [type] => int     [len] => 11     [flags] => primary_key not_null )

DB_TABLEINFO_ORDER

In addition to the information found in the default output, a notation of the number of columns is provided by the num_fields element while the order element provides an array with the column names as the keys and their location index number (corresponding to the keys in the default output) as the values.

If a result set has identical field names, the last one is used.

[num_fields] => 3 [order] => Array (     [fldId] => 2     [fldTrans] => 1 )

DB_TABLEINFO_ORDERTABLE

Similar to DB_TABLEINFO_ORDER but adds more dimensions to the array in which the table names are keys and the field names are sub-keys. This is helpful for queries that join tables which have identical field names.

[num_fields] => 3 [ordertable] => Array (     [tblFoo] => Array (         [fldId] => 0         [fldPhone] => 1     )     [tblBar] => Array (         [fldId] => 2     ) )

DB_TABLEINFO_FULL

Contains the information from both DB_TABLEINFO_ORDER and DB_TABLEINFO_ORDERTABLE

The tableInfo mode constants are bitwised, so they can be combined using |.

Note

This function can not be called statically.

tableInfo() is not portable because not all drivers have this capability and the data returned by each DBMS varies wildly.

Who's Online
Guest Users: 9
Google
Web
WeberTrivia
WeberDev
WeberForums
 Free Sample Chapters  Free Sample Chapters
  Deliver First Class Web Sites: 101 Essential Checklists
Want to learn how to make your web sites usable and accessible? Want to ensure that your sites meet current best practice, without spending hours trawling through incomprehensible specifications and recommendations from dozens of different books, research papers, and web sites? Want to make sure that the sites you build are "right the first time," requiring no costly redevelopments?

More Sample Chapters

PHP General