I am trying to update a website from SS 2.4 to SS 3.1 and have been digging around the web on this issue for a while now.
The old code looks like this...
return DataObject::get('SupportItem', "SupportItemType = '$itemType' AND ProductPageID = $productID", null, 'INNER JOIN SupportItem_Products ON SupportItem_Products.SupportItemID = SupportItem.ID');
I am trying to switch out of the deprecated INNER JOIN and DataObject::get to the now current innerJoin and DataobjectName::get. This is what I have for the new code
$productID = $this->productToView->ID;
return SupportProductListingPage::get()->innerJoin('SupportItem_Products', '"SupportItem_Products"."SupportItemID" = "SupportItem"."ID"', null)->filter(array('SupportItemType'=>'$itemType', 'ProductPageID' => '$productID'));
It should be noted that the "SupportItemID" column exists in "SupportItem_Products" and the "ID" column exists in "SupportItem". However, "SupportItemID" does not exist in the "SupportItem" table.
I am receiving the below error when loading the page...
[User Error] Couldn't run query: SELECT DISTINCT count(DISTINCT "SiteTree"."ID") AS "0" FROM "SiteTree" LEFT JOIN "Page" ON "Page"."ID" = "SiteTree"."ID" INNER JOIN "SupportItem_Products" ON "SupportItem_Products"."SupportItemID" = "SupportItem"."ID" WHERE ("ProductPageID" = '$productID') AND ("SiteTree"."ClassName" IN ('SupportProductListingPage')) Unknown column 'SupportItem.ID' in 'on clause'
Can anyone help?