Search

Is there a function in the database class of symphony to check if a certain table exists?

There isn’t. But you can run a query yourself through the Database->query() method:

SELECT table_name FROM information_schema.tables WHERE table_schema = 'databasename' AND table_name = 'your_table_name';

Or when you come to create your table, check that it doesn’t exist first:

CREATE TABLE IF NOT EXISTS `your_table_name` ...

Good tip, nick.

Perhaps a nice feature to have in Symphony 2.0.8?

boolean Database->table_exists($tableName)

What case do you need this?

For my extension. To check if a certain table exists. After I create an ensemble, the reference to my extension is still in the extensions-table. But the table created by my extension gets not exported when creating the ensemble.

Or should this be considered a missing feature in the ‘export ensemble’-extension?

Or should this be considered a missing feature in the ‘export ensemble’-extension?

It was specifically designed to work like this.

What exactly are you trying to do? It sounds like you wanted to check if the extension is properly installed every time you run it.

Yes, that’s I want to do.

Otherwise, when I create an ensemble the table created with my extension doesn’t get exported, but the extension itself and the reference to it in the database do get exported. This was throwing my ensemble an error when I installed it, because the table where my enabled extension depended on didn’t exist.

So I thought: check if the table exists before you go any further to make sure no errors get thrown.

Otherwise, when I create an ensemble the table created with my extension doesn’t get exported, but the extension itself and the reference to it in the database do get exported.

I don’t think extensions should be held responsible for doing that. Maybe I can win you for my side of the discussion that export ensemble should be extended to also export custom extension tables. :-)

We do intend to update the export ensemble to allow for options to include custom extension tables. We just need to finish 2.0.8, 2.1 and various Symphony website upgrades first.

export ensemble should be extended to also export custom extension tables.

Exactly my point!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details