Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Problem with DOM PopUp Display [solved]

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 722 Views
  • Hello_electro
    Avatar
    Community Member
    80 Posts

    Problem with DOM PopUp Display [solved] Link to this post

    Hi Everyone.

    I am having a peculiar error that I cant seem to locate the issue. I am simply creating a DOM to display news articles. I have successfully created the page and added articles within the CMS. The problem is when I click on the edit button for one of the items, i get an error message about a query issue.

    I tried to just start all the way in the begining and use a working example from uncle Cheese's Testimonial code. Still no progress.

    I am pasting my code below, along with the error. Maybe I am missing something small, or this is something larger?

    Here is the NewsArticlePage code

    <?php
    class DPSNewsArticlePage extends Page
    {
       static $has_many = array (
          'DPSNewsArticles' => 'DPSNewsArticle'
       );
       
       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $manager = new DataObjectManager(
             $this, // Controller
             'DPSNewsArticles', // Source name
             'DPSNewsArticle', // Source class
             array('Date' => 'Date', 'Author' => 'Author', 'Quote' => 'Quote'), // Headings
             'getCMSFields_forPopup' // Detail fields function or FieldSet
             // Filter clause
             // Sort clause
             // Join clause
          );
          
          
          $f->addFieldToTab("Root.Content.Articles", $manager);
          
          return $f;
       }

    }
    class DPSNewsArticlePage_Controller extends Page_Controller
    {
    }
    ?>


    DPS News Article code

    <?php
    class DPSNewsArticle extends DataObject
    {
       static $db = array (
          'Date' => 'Date',
          'Author' => 'Text',
          'Quote' => 'Text'
       );
       
       static $has_one = array (
          'DPSNewsArticlePage' => 'DPSNewsArticle'
       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new DatePickerField('Date'),
             new TextField('Author'),
             new TextareaField('Quote')
          );
       }
    }
    ?>

    Error Message

    User Error] Couldn't run query: SELECT "DPSNewsArticle"."ClassName", "DPSNewsArticle"."Created", "DPSNewsArticle"."LastEdited", "DPSNewsArticle"."Date", "DPSNewsArticle"."Author", "DPSNewsArticle"."Quote", "DPSNewsArticle"."DPSNewsArticlePageID", "DPSNewsArticle"."ID", CASE WHEN "DPSNewsArticle"."ClassName" IS NOT NULL THEN "DPSNewsArticle"."ClassName" ELSE 'DPSNewsArticle' END AS "RecordClassName" FROM "DPSNewsArticle" WHERE ("ParentID" = '214') Unknown column 'ParentID' in 'where clause'
    GET /publicsafety/admin/EditForm/field/DPSNewsArticles/item/2/edit?SecurityID=2c5824d7f11f37de6195cc76ba911620d6261ded&ctf[DPSNewsArticles][start]=0&ctf[DPSNewsArticles][per_page]=10&ctf[DPSNewsArticles][showall]=0&ctf[DPSNewsArticles][sort]=&ctf[DPSNewsArticles][sort_dir]=&ctf[DPSNewsArticles][search]=&ctf[DPSNewsArticles][filter]=

    Line 525 in /usr/local/ftp/publicsafety/html/sapphire/core/model/MySQLDatabase.php
    Source

    516    }
    517    
    518    function databaseError($msg, $errorLevel = E_USER_ERROR) {
    519       // try to extract and format query
    520       if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
    521          $formatter = new SQLFormatter();
    522          $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
    523       }
    524       
    525       user_error($msg, $errorLevel);
    526    }
    527    
    528    /**
    529     * Return a boolean type-formatted string
    530     *
    531     * @param array $values Contains a tokenised list of info about this data type

    Trace

    * Couldn't run query: SELECT "DPSNewsArticle"."ClassName", "DPSNewsArticle"."Created", "DPSNewsArticle"."LastEdited", "DPSNewsArticle"."Date", "DPSNewsArticle"."Author", "DPSNewsArticle"."Quote", "DPSNewsArticle"."DPSNewsArticlePageID", "DPSNewsArticle"."ID", CASE WHEN "DPSNewsArticle"."ClassName" IS NOT NULL THEN "DPSNewsArticle"."ClassName" ELSE 'DPSNewsArticle' END AS "RecordClassName" FROM "DPSNewsArticle" WHERE ("ParentID" = '214') Unknown column 'ParentID' in 'where clause'
    Line 525 of MySQLDatabase.php
    * MySQLDatabase->databaseError(Couldn't run query: SELECT "DPSNewsArticle"."ClassName", "DPSNewsArticle"."Created", "DPSNewsArticle"."LastEdited", "DPSNewsArticle"."Date", "DPSNewsArticle"."Author", "DPSNewsArticle"."Quote", "DPSNewsArticle"."DPSNewsArticlePageID", "DPSNewsArticle"."ID", CASE WHEN "DPSNewsArticle"."ClassName" IS NOT NULL THEN "DPSNewsArticle"."ClassName" ELSE 'DPSNewsArticle' END AS "RecordClassName" FROM "DPSNewsArticle" WHERE ("ParentID" = '214') | Unknown column 'ParentID' in 'where clause',256)
    Line 123 of MySQLDatabase.php
    * MySQLDatabase->query(SELECT "DPSNewsArticle"."ClassName", "DPSNewsArticle"."Created", "DPSNewsArticle"."LastEdited", "DPSNewsArticle"."Date", "DPSNewsArticle"."Author", "DPSNewsArticle"."Quote", "DPSNewsArticle"."DPSNewsArticlePageID", "DPSNewsArticle"."ID", CASE WHEN "DPSNewsArticle"."ClassName" IS NOT NULL THEN "DPSNewsArticle"."ClassName" ELSE 'DPSNewsArticle' END AS "RecordClassName" FROM "DPSNewsArticle" WHERE ("ParentID" = '214'),256)
    Line 129 of DB.php
    * DB::query(SELECT "DPSNewsArticle"."ClassName", "DPSNewsArticle"."Created", "DPSNewsArticle"."LastEdited", "DPSNewsArticle"."Date", "DPSNewsArticle"."Author", "DPSNewsArticle"."Quote", "DPSNewsArticle"."DPSNewsArticlePageID", "DPSNewsArticle"."ID", CASE WHEN "DPSNewsArticle"."ClassName" IS NOT NULL THEN "DPSNewsArticle"."ClassName" ELSE 'DPSNewsArticle' END AS "RecordClassName" FROM "DPSNewsArticle" WHERE ("ParentID" = '214'),256)
    Line 400 of SQLQuery.php
    * SQLQuery->execute()
    Line 1268 of DataObject.php
    * DataObject->getComponents(DPSNewsArticles)
    Line 532 of ComplexTableField.php
    * ComplexTableField->getFieldsFor(DPSNewsArticle)
    Line 792 of ComplexTableField.php
    * ComplexTableField_ItemRequest->DetailForm()
    Line 931 of DataObjectManager.php
    * DataObjectManager_ItemRequest->DetailForm()
    Line 369 of ViewableData.php
    * ViewableData->obj(DetailForm,,1)
    Line 32 of .cache.dataobject_manager.templates.DataObjectManager_popup.ss
    * include(/usr/local/ftp/publicsafety/html/silverstripe-cache/.cache.dataobject_manager.templates.DataObjectManager_popup.ss)
    Line 420 of SSViewer.php
    * SSViewer->process(DataObjectManager_ItemRequest)
    Line 342 of ViewableData.php
    * ViewableData->renderWith(DataObjectManager_popup)
    Line 948 of DataObjectManager.php
    * DataObjectManager_ItemRequest->edit(SS_HTTPRequest)
    Line 143 of RequestHandler.php
    * RequestHandler->handleRequest(SS_HTTPRequest)
    Line 161 of RequestHandler.php
    * RequestHandler->handleRequest(SS_HTTPRequest)
    Line 161 of RequestHandler.php
    * RequestHandler->handleRequest(SS_HTTPRequest)
    Line 161 of RequestHandler.php
    * RequestHandler->handleRequest(SS_HTTPRequest)
    Line 147 of Controller.php
    * Controller->handleRequest(SS_HTTPRequest)
    Line 282 of Director.php
    * Director::handleRequest(SS_HTTPRequest,Session)
    Line 125 of Director.php
    * Director::direct(/admin/EditForm/field/DPSNewsArticles/item/2/edit)
    Line 127 of main.php

  • UncleCheese
    Avatar
    4085 Posts

    Re: Problem with DOM PopUp Display [solved] Link to this post

    Are you sure this is what you want??

    static $has_one = array (
    'DPSNewsArticlePage' => 'DPSNewsArticle'
    );

    Look at that closely.

  • Hello_electro
    Avatar
    Community Member
    80 Posts

    Re: Problem with DOM PopUp Display [solved] Link to this post

    Doh! Yes, I see it now. I changed to below and it works. Thanks UC. I appreciate you taking time to point this out. I actually like that you turned it back on me to see it. Good way to learn form my mistake.

    static $has_one = array (
    'DPSNewsArticlePage' => 'DPSNewsArticlePage'
    );

    722 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.