function systemSetup() { try { /*use the DbQuery's static 'connect' method to connect to the database*/ Query::connect(); if (constant('DEVELOPMENT')) { $query = SimpleQuery::create('SHOW TABLES FROM ' . constant('DB_NAME') . ' LIKE \'%_access\''); if (!$query->numRows()) { Query::importFile('packages/pilot/pilot.sql'); } } } catch (DbNotFoundException $exc) { if (constant('DB_NAME')) { if (mysql_query('CREATE DATABASE ' . constant('DB_NAME'))) { Query::connect(); Query::importFile('packages/pilot/pilot.sql'); } else { throw new DbConnectException('I don\'t have permission to create your database for you, please create the database ' . constant('DB_NAME') . ' manually and then import the file packages/pilot/pilot.sql into it'); } } } }