Where the heck did the developer docs go?  Bottom

  • I would like to know where the heck the developer documentation to postnuke went. Im trying to create a module and creating the table is failing and I cant find an API doc or anything. In the meantime, could anyone please tell me what I am doing wrong here. In the following code the first table doesnt create and the database gives a failure. I get the printout:

    Code

    Create table Failed: pn_agony_eve_skill1064


    Code

    function Agony_init() {
        // Get datbase setup - note that both pnDBGetConn() and pnDBGetTables()
        // return arrays but we handle them differently.  For pnDBGetConn()
        // we currently just want the first item, which is the official
        // database handle.  For pnDBGetTables() we want to keep the entire
        // tables array together for easy reference later on
        $dbconn = & pnDBGetConn(true);
        $pntable = & pnDBGetTables();

        // -- Create tables
        $agony_eve_skill_table = $pntable['agony_eve_skill'];
        $agony_eve_skill_column = & $pntable['agony_eve_skill_column'];
        $sql = "CREATE TABLE $agony_eve_skill_table (
                    $agony_eve_skill_column[id] INTEGER NOT NULL AUTO_INCREMENT UNIQUE,
                    $agony_eve_skill_column[name] VARCHAR(30) UNIQUE,
                    PRIMARY KEY  ($agony_eve_skill_column[id])
                )"
    ;
        $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            echo "Create table Failed: $agony_eve_skill_table";
            echo $dbconn->ErrorNo();
            return false;   
        }


        $agony_pilot_table = $pntable['agony_pilot'];
        $agony_pilot_column = & $pntable['agony_pilot_column'];
        $sql = "CREATE TABLE $agony_pilot_table (
                    $agony_pilot_column[id] INTEGER NOT NULL AUTO_INCREMENT UNIQUE,
                    $agony_pilot_column[name] VARCHAR(30) NOT NULL,
                    $agony_pilot_column[birthdate] DATE NOT NULL,
                    $agony_pilot_column[ticker] VARCHAR(10) NOT NULL,
                    $agony_pilot_column[pn_uid] INTEGER,
                    PRIMARY KEY($agony_pilot_column[id])
                    FOREIGN KEY($agony_pilot_column[pn_uid])
                            REFERENCES pn_users(pn_uid),
                    CONSTRAINT agony_ap_c1 UNIQUE($agony_pilot_column[name],
                                                  $agony_pilot_column[birthdate])
                )"
    ;
        $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            echo "Create table Failed: $agony_pilot_table";
            return false;   
        }


        $agony_pilot_buddy_table = $pntable['agony_pilot_buddy'];
        $agony_pilot_buddy_column = & $pntable['agony_pilot_buddy_column'];
        $sql = "CREATE TABLE $agony_pilot_buddy_table (
                    $agony_pilot_buddy_column[pilot_id] INTEGER NOT NULL,
                    $agony_pilot_buddy_column[buddy_id] INTEGER NOT NULL,
                )"
    ;
        $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            echo "Create table Failed: $agony_seminar_table";
            return false;   
        }


        $agony_seminar_type_table = $pntable['agony_seminar_type'];
        $agony_seminar_type_column = & $pntable['$agony_seminar_type_column'];
        $sql = "CREATE TABLE $agony_seminar_type_table (
                    $agony_seminar_type_column[id] INTEGER NOT NULL AUTO_INCREMENT UNIQUE,
                    $agony_seminar_type_column[name] VARCHAR(30) NOT NULL UNIQUE,
                    $agony_seminar_type_column[description] VARCHAR(10000) NOT NULL,
                    $agony_seminar_type_column[forum_id] SMALLINT(5) NOT NULL,
                    $agony_seminar_type_column[forum_group_id] MEDIUMINT(8) NOT NULL,
                    FOREIGN KEY($agony_seminar_type_column[forum_group_id])
                            REFERENCES pn_phpbb_groups(group_id),
                    FOREIGN KEY($agony_seminar_type_column[forum_id])
                            REFERENCES pn_phpbb_forums(forum_id)
                    PRIMARY KEY($agony_seminar_type_column[id])
                )"
    ;
        $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            echo "Create table Failed: $agony_eve_skill_table";
            return false;   
        }


        $agony_seminar_table = $pntable['agony_seminar'];
        $agony_seminar_column = & $pntable['agony_seminar_column'];
        $sql = "CREATE TABLE $agony_seminar_table (
                    $agony_seminar_type_column[id] INTEGER NOT NULL AUTO_INCREMENT UNIQUE,
                    $agony_seminar_type_column[code] VARCHAR(45) NOT NULL UNIQUE,
                    $agony_seminar_type_column[seminar_type_id] INTEGER NOT NULL,
                    $agony_seminar_type_column[cost] INTEGER NOT NULL,
                    $agony_seminar_type_column[location] VARCHAR(45) NOT NULL,
                    $agony_seminar_type_column[instructor] INTEGER NOT NULL,
                    $agony_seminar_type_column[eve_date_time] DATETIME NOT NULL,
                    $agony_seminar_type_column[duration_hours] DECIMAL(5,2) NOT NULL,
                    $agony_seminar_type_column[eve_online_thread] VARCHAR(512),
                    $agony_seminar_type_column[notes] VARCHAR(2000) DEFAULT '' NOT NULL,
                    $agony_seminar_type_column[created_by] INTEGER NOT NULL,
                    PRIMARY KEY($agony_seminar_type_column[id]),
                    FOREIGN KEY($agony_seminar_type_column[seminar_type_id])
                            REFERENCES $agony_seminar_type_table($agony_seminar_type_column[id]),
                    FOREIGN KEY($agony_seminar_type_column[instructor])
                            REFERENCES $agony_pilot_table($agony_pilot_column[id]),
                    FOREIGN KEY($agony_seminar_type_column[created_by])
                            REFERENCES pn_users(pn_uid),
                    CONSTRAINT agony_as_c1 UNIQUE($agony_seminar_type_column[seminar_type_id],
                                                  $agony_seminar_type_column[eve_date_time]),
                    CONSTRAINT agony_as_c2 CHECK($agony_seminar_type_column[cost] < 0)
                )"
    ;
        $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            echo "Create table Failed: $agony_seminar_table";
            return false;   
        }


        $agony_prereq_skill_table = $pntable['agony_prereq_skill'];
        $agony_prereq_skill_column = & $pntable['$agony_prereq_skill_column'];
        $sql = "CREATE TABLE $agony_prereq_skill_table (
                    $agony_prereq_skill_column[seminar_type_id] INTEGER NOT NULL,
                    $agony_prereq_skill_column[eve_skill_id] INTEGER NOT NULL,
                    $agony_prereq_skill_column[level] INTEGER   DEFAULT 1 NOT NULL,
                    $agony_prereq_skill_column[required] BOOLEAN DEFAULT 1 NOT NULL,
                    FOREIGN KEY($agony_prereq_skill_column[seminar_type_id])
                            REFERENCES $agony_seminar_type_table($agony_seminar_type_column[id]),
                    FOREIGN KEY($agony_prereq_skill_column[eve_skill_id])
                            REFERENCES $agony_eve_skill_table($agony_eve_skill_column[id]),
                    CONSTRAINT agony_apsk_c1 UNIQUE($agony_prereq_skill_column[seminar_type_id],
                                                    $agony_prereq_skill_column[eve_skill_id]),
                    CONSTRAINT agony_apsk_c2 CHECK($agony_prereq_skill_column[level] > 0),
                    CONSTRAINT agony_apsk_c3 CHECK($agony_prereq_skill_column[level] < 6)
                )"
    ;
        $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            echo "Create table Failed: $agony_prereq_skill_table";
            return false;   
        }



        $agony_prereq_seminar_table = $pntable['agony_prereq_seminar'];
        $agony_prereq_seminar_column = & $pntable['agony_prereq_seminar_column'];
        $sql = "CREATE TABLE $agony_prereq_seminar_table (
                    $agony_prereq_seminar_column[seminar_type_id] INTEGER NOT NULL,
                    $agony_prereq_seminar_column[prereq_seminar_type_id] INTEGER NOT NULL,
                    FOREIGN KEY($agony_prereq_seminar_column[seminar_type_id])
                            REFERENCES $agony_seminar_type_table($agony_seminar_type_column[id])],
                    FOREIGN KEY($agony_prereq_seminar_column[prereq_seminar_type_id])
                            REFERENCES $agony_seminar_type_table($agony_seminar_type_column[id]),
                    CONSTRAINT agony_aps_c1 UNIQUE($agony_prereq_seminar_column[seminar_type_id],
                                                   $agony_prereq_seminar_column[prereq_seminar_type_id])
                )"
    ;
        $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            echo "Create table Failed: $agony_prereq_seminar_table";
            return false;   
        }


        $agony_attending_pilot_table = $pntable['agony_attending_pilot'];
        $agony_attending_pilot_column = & $pntable['agony_attending_pilot_column'];
        $sql = "CREATE TABLE $agony_attending_pilot_table (
                    $agony_attending_pilot_column[pilot_id] INTEGER NOT NULL,
                    $agony_attending_pilot_column[seminar_id] INTEGER NOT NULL,
                    $agony_attending_pilot_column[paid] BOOLEAN DEFAULT 0 NOT NULL,
                    $agony_attending_pilot_column[attended] BOOLEAN DEFAULT 0 NOT NULL,
                    $agony_attending_pilot_column[has_credit] BOOLEAN DEFAULT 0 NOT NULL,
                    $agony_attending_pilot_column[buddy_id] INTEGER NOT NULL,
                    $agony_attending_pilot_column[notes] VARCHAR(3000) DEFAULT '',
                    FOREIGN KEY($agony_attending_pilot_column[pilot_id])
                            REFERENCES $agony_pilot_table($agony_pilot_column[id]),
                    FOREIGN KEY($agony_attending_pilot_column[buddy_id])
                            REFERENCES $agony_pilot_table($agony_pilot_column[id]),
                    FOREIGN KEY($agony_attending_pilot_column[seminar_id])
                            REFERENCES $agony_seminar_table($agony_seminar_column[id]),
                    CONSTRAINT agony_aap_c1 UNIQUE($agony_attending_pilot_column[pilot_id],
                                                   $agony_attending_pilot_column[seminar_id])
                )"
    ;
        $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            echo "Create table Failed: $agony_attending_pilot_table";
            return false;   
        }


        // -- Set up config variables
        pnConfigSetVar('Agony', 1);
        return true;
    }


  • Your SQL is wrong - echo it out of the code during your initialize function and review it for errors.

    Developer documentation is now contained in the Wiki (see the link on the left).

    The API guide has disappeared, but this will go back online shortly (and eventually be moved into the Wiki)

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • To see the error generated by MySQL

    Code

    echo "Create table Failed: $agony_pilot_table - ".$dbconn->ErrorMsg();

This list is based on users active over the last 60 minutes.