This blog embraces totally the foundamentals of the Open Source Spirit and Soul. Hence all material founded here is free and the user may read, copy, manipulate, reproduce it all, without limitations of any kind, no copyright allowed here!
Nevertheless the author will appreciate if the user will cite him, when using his scripts, as a recognition of his work.
Knowledge is the prime right of umanity and has to be protected and shared with every possible means.
abidibo.

Friday, July 9, 2010

Get MySQL table data structure with PHP

Hi, today I'll show how to retrieve informations about a MySQL table through php in order for example to create a php class making editable a table in an automatic way (that is: stupid class, i give you a name of a table and YOU have to create its backend for me). This work is done very well by the python framework Django for example.
Now, there are several ways to do so, I'll use the interrogation of the information_schema db.
Well, let's see the code. I post here a simple function, clearly the informations that may be retrieved are more than these.