RE: [PHP] If Column Exists
| From: | Per Jessen | Date: | Wed, 13 Aug 2008 08:02:52 +0000 |
| Subject: | RE: [PHP] If Column Exists | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278022@lists.php.net to get a copy of this message | ||
Jay Blanchard wrote:
> [snip]
> I am working on data migration for one mysql db to another using PHP.
> How do
> I check if a particular table has a particular column. If not alter....
> [/snip]
>
> Use DESCRIBE TABLE;
>
Then you'd have to parse the output - how about
SELECT <column> FROM <table> LIMIT 1 ?
The query will fail if the column doesn't exist.
/Per Jessen, Zürich