Software is like sex... It's better when it's free.

Blog - Retrieve the comments table and comments columns in mysql

Retrieve the comments table and comments columns in mysql

If you are interested in MySQL (or PHP) recover comments tables and / or comments from the columns of a table, remember that it is very easy to access this information directly from a query.

Retrieving comments for a table :

# 'sillysmart' is the name of the database you want to extract information
mysql> SHOW TABLE STATUS FROM sillysmart 
mysql> 

will produce the following informations:

Name Engine Version Rows Comment
Country MyISAM 10 240 Countries Listing
News MyISAM 10 30 News Listing

Where the column 'Comment' will give you the information, the commentary of the table. Know that many other informations are available through this application.

Retrieve the comments columns of a table :

# 'Country' is the table name you want
mysql> SHOW FULL COLUMNS FROM Country 
mysql> 

will produce the following informations:

Field Type Collation Null Key Extra Privileges Comment
country_id bigint(20) NULL NO PRI auto_increment select,insert,update Id
country_name varchar(255) latin1_swedish_ci NO UNI   select,insert,update Country Name
country_tld varchar(2) latin1_swedish_ci YES     select,insert,update Country TLD

Where the column 'Comment' will give you the information, the comment column of the table.

Free for you to use this information in PHP. Personally we use these columns in a transparent way on SillySmart to create generic back-office remains speaking for a non-scientist. The only constraint is that the length of the commentary is limited to 60 characters, so be succinct!

Tags:  mysqlphp.
Posted the Monday 08 june 2009 15:45:08

Comments :

Domi, the monday 22 june 2009 16:14:50
Bien pratique.

merci