[drupal-devel] Detecting table existence/absence in a Drupally-correct way

Adrian Rossouw adrian at daemon.co.za
Thu Apr 14 13:30:49 UTC 2005

Hash: SHA1

I wrote db_table_exists and a db_column_exists functions recently for 
the install system, if you want them ?

What are you using it for ?

On 14 Apr 2005, at 4:39 AM, Gerhard Killesreiter wrote:

> On Wed, 13 Apr 2005, Syscrusher wrote:
>> Good evening!
> Goood morning!
>> Is there a well-behaved way to use Drupal's DB abstraction to find
>> out if a table exists? I'm working on a migration feature, and need
>> to be able to detect the existence of the table so that I can issue
>> a user-friendly "you don't need to do this step" message if the
>> table isn't there.
> You could do "CREATE TABLE IF NOT EXISTS foo ...." and take out the 
> user
> intervention completely.
> sed -e 's/CREATE TABLE \([a-z0-9_]*\)/CREATE TABLE IF NOT EXISTS \1/' \
> < database.mysql > database-if-exists.mysql
> should create a proper Drupal db file with that clause for all tables.
> Cheers,
> 	Gerhard
- --
Adrian Rossouw
Drupal developer and Bryght Guy
http://drupal.org | http://bryght.com

Version: GnuPG v1.2.4 (Darwin)


More information about the drupal-devel mailing list