/** * Implementation of hook_init. */ function ft_fileinfo_init() { // Check if DB plugin is loaded. if (!ft_plugin_exists('db')) { ft_set_message(t('!name plugin not enabled because required !required plugin was not found.', array('!name' => 'Fileinfo', '!required' => 'db')), 'error'); ft_plugin_unload('fileinfo'); } else { // Check if we need to create new table. $sql = "CREATE TABLE fileinfo (\n dir TEXT NOT NULL,\n file TEXT NOT NULL,\n description TEXT\n )"; ft_db_install_table('fileinfo', $sql); } }
/** * Implementation of hook_init. */ function ft_db_init() { global $ft; if (extension_loaded('pdo_sqlite')) { if ($ft['db']['link'] = new PDO('sqlite:' . $ft['plugins']['db']['settings']['path'])) { // Get a list of tables. That way other modules can determine if they need to install themselves or not. $result = $ft['db']['link']->query("SELECT name FROM SQLITE_MASTER WHERE type='table'"); if ($result) { foreach ($result as $row) { $ft['db']['tables'][] = $row['name']; } } } else { ft_set_message(t('Database module could not be enabled. Database could not be created at !db.', array('!db' => $ft['plugins']['db']['settings']['path'])), 'error'); ft_plugin_unload('db'); } } else { ft_set_message(t('Database module could not be enabled. PHP PDO is not installed.'), 'error'); ft_plugin_unload('db'); } }