Fork me on GitHub

init and pntables issue?  Bottom

  • i was following the example module from 750. just wanted to make sure i was doin this right, cuz something is broke with my module, and i think i initialized it wrong/.


    Code

    function RiddimDB_init()
    {
        $dbconn =& pnDBGetConn(true);
        $pntable =& pnDBGetTables();

        // creating artist table
        $RiddimDBArtisttable = $pntable['profile_artist'];
        $RiddimDBArtistcolumn = &$pntable['profile_artist_column'];

        $sql = "CREATE TABLE $RiddimDBArtisttable (
                $RiddimDBArtistcolumn[tid] int(10) NOT NULL auto_increment,
                $RiddimDBArtistcolumn[itemname] varchar(32) NOT NULL default '',
                $RiddimDBArtistcolumn[desc] text NOT NULL default '',
                $RiddimDBArtistcolumn[img] varchar(60) NOT NULL default '',
                $RiddimDBArtistcolumn[link1] varchar(60) NOT NULL default '',
                $RiddimDBArtistcolumn[link2] varchar(60) NOT NULL default '',
                $RiddimDBArtistcolumn[link3] varchar(60) NOT NULL default '',
                $RiddimDBArtistcolumn[number] int(5) NOT NULL default 0,
                PRIMARY KEY(pn_tid))"
    ;
            $dbconn->Execute($sql);

            if ($dbconn->ErrorNo() != 0) {
                pnSessionSetVar('errormsg', _DBCREATETABLEERROR . " $riddimuptable db err no " . $dbconn->ErrorNo());
                return false;
        }

        // creating riddimtable
        $RiddimDBRiddimtable = $pntable['profile_riddim'];
        $RiddimDBRiddimcolumn = &$pntable['profile_riddim_column'];

        $sql = "CREATE TABLE $RiddimDBRiddimtable (
                $RiddimDBRiddimcolumn[tid] int(10) NOT NULL auto_increment,
                $RiddimDBRiddimcolumn[itemname] varchar(32) NOT NULL default '',
                PRIMARY KEY(pn_tid))"
    ;
            $dbconn->Execute($sql);

            if ($dbconn->ErrorNo() != 0) {
                pnSessionSetVar('errormsg', _DBCREATETABLEERROR . " $riddimuptable db err no " . $dbconn->ErrorNo());
                return false;
        }




        pnModSetVar('RiddimDB', 'bold', 0);
        pnModSetVar('RiddimDB', 'itemsperpage', 10);

        return true;
    }
  • this is the pntable file

    Code

    function RiddimDB_pntables()
    {

        // Initialise table array
        $pntable = array();

        $RiddimDB_artist = pnConfigGetVar('prefix') . '_profile_artist';
        $pntable['profile_artist'] = $RiddimDB_artist;
        $pntable['profile_artist_column'] = array('tid'         => $RiddimDB_artist . '.pn_tid',
                                           'itemname'   => $RiddimDB_artist . '.pn_name',
                                           'desc'       => $RiddimDB_artist . '.pn_desc',
                                           'img'        => $RiddimDB_artist . '.pn_img',
                                           'link1'      => $RiddimDB_artist . '.pn_link1',
                                           'link2'      => $RiddimDB_artist . '.pn_link2',
                                           'link3'      => $RiddimDB_artist . '.pn_link3',
                                           'number'     => $RiddimDB_artist . '.pn_number');


        $RiddimDB_riddim = pnConfigGetVar('prefix') . '_profile_riddim';
        $pntable['profile_riddim'] = $RiddimDB_riddim;
        $pntable['profile_riddim_column'] = array('tid' => $RiddimDB_riddim . '.pn_tid',
                                           'itemname' => $RiddimDB_artist . '.pn_itemname');

        return $pntable;
    }
  • So what's the problem exactly?

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • i took the example module, and i was editing it.

    i took the view function, and duplicated it. now i have view_artist and view_riddim

    the view_artist works, but for some reason the view_riddim doesnt


    i also duplicated the helper functions as well (get_riddim, countriddims etc).


    after troubleshooting to pinpoint the problem. i see that it would pull from the artist table, but not the riddim table.


    my suspicion is that the problem is an issue with how i initialized the module (riddim table
  • Have you tried debugging the SQL queries you're using in your functions first?

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • dont know how?
  • echo out the SQL statement, then copy it into phpMyAdmin and see if it works...

    There's the odd topic on debugging in this forum. You might find it of value to read them

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • HammerHead

    echo out the SQL statement, then copy it into phpMyAdmin and see if it works...

    There's the odd topic on debugging in this forum. You might find it of value to read them


    k i'll check it out when i get home from work.

    i'll let ya know wha gwaan
  • thank god for

    print_r($SQL);
    die;


    i fount the error, it was in the pntables file.
  • cannibus

    thank god for

    print_r($SQL);
    die;


    ...no doubt about...

    You can also use vardump($varName) for some nice results...

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