Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions

Strange problem with LEFT JOIN


Reply

3 Posts   1504 Views

Avatar
Victor

30 November 2009 at 2:46am (Last edited: 30 November 2009 2:48am), Community Member, 128 Posts

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

Avatar
Willr

30 November 2009 at 9:03am (Last edited: 30 November 2009 9:03am), Forum Moderator, 5511 Posts

it returns an error

Whats the error?

Avatar
Victor

30 November 2009 at 10:31am Community Member, 128 Posts

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