Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Strange problem with LEFT JOIN

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

Page: 1
Go to End
Author Topic: 1445 Views
  • Victor
    Avatar
    Community Member
    128 Posts

    Strange problem with LEFT JOIN Link to this post

    The following external (not SilverStripe) php script works:

    $query ="SELECT * FROM `CalendarDateTime` JOIN `SeminarDateTime` ON CalendarDateTime.ID=SeminarDateTime.ID JOIN `SeminarEvent` ON CalendarDateTime.EventID=SeminarEvent.ID ORDER BY StartDate,StartTime";
    $result = mysql_query($query);

    and the following SilverStripe snippet works

    $resultss = DataObject::get("CalendarDateTime","");

    but when I try to extend it (even in shorter version)

    $resultss = DataObject::get("CalendarDateTime"," "," ", "LEFT JOIN `SeminarDateTime` ON `CalendarDateTime`.ID=`SeminarDateTime`.ID" );


    it returns an error

    Any ideas what I am doing wrong? Thank you in advance

    Victor

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Strange problem with LEFT JOIN Link to this post

    it returns an error

    Whats the error?

  • Victor
    Avatar
    Community Member
    128 Posts

    Re: Strange problem with LEFT JOIN Link to this post

    Here I am really puzzled: if I comment out

    //Director::set_environment_type("dev");


    then as I wrote snippet

    $resultss = DataObject::get("CalendarDateTime","");


    works as expected (albeit it is not my goal). But in "dev" mode even working code blows up

    [Warning] Missing argument 1 for HomePage_Controller::doSeminarSearchAll()
    GET /testsite/

    Line 23 in /Applications/MAMP/htdocs/testsite/misc/code/HomePage.php

    Source

    14 return new Form(
    15 $this,
    16 "SeminarSearchFormAll",
    17 "",
    18 new FieldSet( new FormAction('doSeminarSearchAll','Display All Seminars'))
    19 );
    20 }
    21
    22
    23 function doSeminarSearchAll($data,$form){
    24 $results = new DataObjectSet();
    25 $resultss = DataObject::get("CalendarDateTime","");
    26 //$resultss = DataObject::get("`CalendarDateTime`","","", "LEFT JOIN `SeminarDateTime` ON `CalendarDateTime`.ID=`SeminarDateTime`.ID LEFT JOIN `SeminarEvent` ON `CalendarDateTime`.EventID=`SeminarEvent`.ID" );
    27 //$resultss = DataObject::get("CalendarDateTime", "", "", "LEFT JOIN `SeminarDateTime` ON `CalendarDateTime`.ID=`SeminarDateTime`.ID" );
    28 $results->merge($resultss);
    29 return $this->customise(array('SeminarSearchResults' => $results))->renderWith(array('SeminarSearch_results'));
    Trace

    HomePage_Controller->doSeminarSearchAll()
    call_user_func_array(Array,Array)
    Line 408 of ViewableData.php
    ViewableData->XML_val(doSeminarSearchAll,,1)
    Line 175 of .cache.Applications.MAMP.htdocs.testsite.misc.templates.Layout.HomePage.ss
    include(/private/var/tmp/silverstripe-cache-Applications-MAMP-htdocs-testsite/.cache.Applications.MAMP.htdocs.testsite.misc.templates.Layout.HomePage.ss)
    Line 354 of SSViewer.php
    SSViewer->process(HomePage_Controller)
    Line 346 of SSViewer.php
    SSViewer->process(HomePage_Controller)
    Line 175 of Controller.php
    Controller->handleAction(HTTPRequest)
    Line 129 of RequestHandler.php
    RequestHandler->handleRequest(HTTPRequest)
    Line 122 of Controller.php
    Controller->handleRequest(HTTPRequest)
    Line 29 of ModelAsController.php
    ModelAsController->handleRequest(HTTPRequest)
    Line 44 of RootURLController.php
    RootURLController->handleRequest(HTTPRequest)
    Line 277 of Director.php
    Director::handleRequest(HTTPRequest,Session)
    Line 121 of Director.php
    Director::direct(/)
    Line 118 of main.php

    1445 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.