1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem with install and uninstall code

Discussion in 'XenForo Development Discussions' started by Matthew Hawley, Jan 14, 2014.

  1. Matthew Hawley

    Matthew Hawley Well-Known Member

    I get this error when I try to save.

    Here is my code for Install.php

    class CF_Directory_Install {
      public static function install($addon) {
        $db = XenForo_Application::get('db');
        $db->query("CREATE TABLE IF NOT EXISTS `xf_ci_directory_pages` (
                      `page_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
                      `route` varchar(25) NOT NULL DEFAULT '',
                      `display_order` int(11) NOT NULL DEFAULT '0',
                      PRIMARY KEY (`page_id`)
                    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;");
    class CF_Directory_Uninstall {
      public static function uninstall() {
        $db = XenForo_Application::get('db');
        $db->query("DROP TABLE `xf_cf_directory_pages`;");
  2. Brogan

    Brogan XenForo Moderator Staff Member

    You are dropping the wrong table: $db->query("DROP TABLE `xf_cf_directory_pages`;");

    Regardless, posting the error message next time would help.
  3. Chris D

    Chris D XenForo Developer Staff Member

    Unrelated but the default charset should be UTF8. Like XenForo.
  4. Matthew Hawley

    Matthew Hawley Well-Known Member

    Ohhh. It actually should be cf. I need to change the ci. :) thanks!
  5. Matthew Hawley

    Matthew Hawley Well-Known Member

    Now when I try it, I get this.

    Parse error: syntax error, unexpected T_CLASS, expecting T_FUNCTION in /home3/xxx/public_html/xxx/library/CF/Directory/Install.php on line 27
  6. Matthew Hawley

    Matthew Hawley Well-Known Member

    Nevermind I got it.
  7. Lawrence

    Lawrence Well-Known Member

    You should also add IF EXISTS to your uninstall drop table:

    $db->query("DROP TABLE IF EXISTS `xf_cf_directory_pages`;");

Share This Page