[drupal-devel] Detecting table existence/absence in a
adrian at daemon.co.za
Thu Apr 14 13:30:49 UTC 2005
-----BEGIN PGP SIGNED MESSAGE-----
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
> 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.
Drupal developer and Bryght Guy
http://drupal.org | http://bryght.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
-----END PGP SIGNATURE-----
More information about the drupal-devel