21/10/2012 7:36am

PHP | Problem - SS3 - Leftjoin


<?php

class ProjectImage extends Image {
public static $default_sort = "Sorting ASC";
public static $has_one = array('ProjectPage' => 'ProjectPage');

public static $db = array(
'Home' => 'Boolean',
);

}
?>


<?php
class ProjectPage extends Page {
static $has_many = array('Images' => 'ProjectImage');
}
?>


<?php
class HomePage extends Page {
public function Images() {

$ar = ProjectPage::get()->leftJoin("ProjectImage", "\"ProjectImage\".\"ProjectPageID\" = \"ProjectPage\".\"ID\"");

return $ar;
}
}
?>

SQL Error:

[User Error] Couldn't run query: SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."URLSegment", "SiteTree_Live"."Title", "SiteTree_Live"."MenuTitle", "SiteTree_Live"."Content", "SiteTree_Live"."MetaTitle", "SiteTree_Live"."MetaDescription", "SiteTree_Live"."MetaKeywords", "SiteTree_Live"."ExtraMeta", "SiteTree_Live"."ShowInMenus", "SiteTree_Live"."ShowInSearch", "SiteTree_Live"."Sort", "SiteTree_Live"."HasBrokenFile", "SiteTree_Live"."HasBrokenLink", "SiteTree_Live"."ReportClass", "SiteTree_Live"."CanViewType", "SiteTree_Live"."CanEditType", "SiteTree_Live"."Version", "SiteTree_Live"."ParentID", "ProjectPage_Live"."FolderID", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" LEFT JOIN "ProjectImage" ON "ProjectImage"."ProjectPageID" = "ProjectPage_Live"."ID" LEFT JOIN "ProjectPage_Live" ON "ProjectPage_Live"."ID" = "SiteTree_Live"."ID" WHERE ("SiteTree_Live"."ClassName" IN ('ProjectPage')) ORDER BY "SiteTree_Live"."Sort" ASC Unknown column 'ProjectPage_Live.ID' in 'on clause'


Post Comment