Fork me on GitHub

Zikula tries to get more from db than whats defined in pntables  Bottom

  • Hello, I've got a weird little problem here. I'm new to making modules in Zikula (only done PN before). I'm having a simple SELECT query but I get this problem:

    Unknown column 'zk_obj_status' in 'field list'
    SELECT genreid AS "genreid",genre AS "genre",zk_obj_status AS "obj_status",zk_cr_date AS "cr_date",zk_cr_uid AS "cr_uid",zk_lu_date AS "lu_date",zk_lu_uid AS "lu_uid" FROM zk_fantasy_genres

    This is the section defining the genretable in pntables:

    Code

    $pntable['genres'] = DBUtil::getLimitedTablename('fantasy_genres');
        $pntable['genres_column'] = array ('genreid'                => 'genreid',
                                           'genre'                  => 'genre');
        $pntable['genres_column_def'] = array('genreid'             => 'I AUTOINCREMENT PRIMARY',
                                           'genre'                  => "C(30) NOT NULL DEFAULT ''");


    This is from the adminapi:

    Code

    function FanTasy_adminapi_genres()
    {
        $pntable = pnDBGetTables();
        $obj = DBUtil::selectObjectArray('genres');
        return $obj;
    }


    and last, from the admin.php

    Code

    function FanTasy_admin_genres()
    {
        if (!SecurityUtil::checkPermission('FanTasy::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }
        $obj = pnModAPIFunc('FanTasy', 'admin', 'genres');
        echo $obj;


        $pnRender = pnRender::getInstance('FanTasy', false);
        return $pnRender->fetch('FanTasy_admin_genres.htm');
    }


    Any idea what is causing the problem? More info needed?
  • Well, seems that your pntables.php adds the standardFields somewhere:

    Code

    ObjectUtil::addStandardFieldsToTableDefinition($pntable['genres_column'],'pn_');
    ObjectUtil::addStandardFieldsToTableDataDefinition($pntable['genres_column_def']);

    that piece of code adds:
    * the pn_obj_status field, and
    * the pn_cr_uid (creator userID),
    * pn_cr_date (creation date),
    * pn_lu_uid (last update userID),
    * pn_lu_date (last update)
    to your table, and using DBUtil those fields are updated automatically.

    Seems that you started to build your module without the standard fields and added their definition after create the Table, and now you have that problem.

    I would recommend you a hacky solution like build a new admin function:

    Code

    function FanTasy_admin_updatetable()
    {
        if (DBUtil::changeTable('genres')) {
            LogUtil::registerStatus(pnML('_UPDATEITEMSUCCEDED', array('i' => 'genres table')));
        } else {
            LogUtil::registerError(_UPDATETABLEFAILED);
        }
        return pnRedirect('FanTasy', 'admin', 'main');
    }


    Then execute /index.php?module=FanTasy&type=admin&func=updatetable

    Now with the table updated with the latest definitions, you'll not have problems with the standard fields icon_wink note that if you don't want (nor need) them on your table, simpli rempve the first two lines of your pntables.php icon_wink

    --
    - Mateo T. -
    Mis principios... son mis fines
  • Ah hah! Now it works!

    Thanks a lot!
    Jeanie

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