query in block template after upgrade breaks site

Permalink
after updating from 5.5.2.1 to 5.6.2.1 this breaks. ideas???

$calIDs = $myDB->execute(" 
  SELECT p.cID FROM Pages p 
  JOIN CollectionVersions cv ON p.cID = cv.cID 
  JOIN PageTypes pt ON p.ctID = pt.ctID 
  WHERE pt.ctHandle = 'calendar_event'
  AND cIsTemplate = 0
  AND cvDatePublic >= SYSDATE()
  AND cvIsApproved = 1
  ORDER BY cvDatePublic
  LIMIT 1
"); 
$eID = $calIDs->fetchRow();
$eventPage = Page::getByID($eID); 
$pageLink = $eventPage->cPath;

 
Remo replied on at Permalink Reply
Remo
It would be easier to help if you'd also post the error message but luckily I've had the same problem before.

Your query fails because the page (collection) type used to be part of "Pages" but has been moved to "CollectionVersions". That happened because the layout of a page is also something that should be versioned.

Long story short, use this:

SELECT p.cID FROM Pages p 
  JOIN CollectionVersions cv ON p.cID = cv.cID 
  JOIN PageTypes pt ON cv.ctID = pt.ctID 
  WHERE pt.ctHandle = 'calendar_event'
  AND cIsTemplate = 0
  AND cvDatePublic >= SYSDATE()
  AND cvIsApproved = 1
  ORDER BY cvDatePublic
  LIMIT 1
jhart replied on at Permalink Reply
remo, thank you for such a quick reply.
that does get the proper cID however i'm still getting an error:

$eID = $calIDs->fetchRow(); 
$eventPage = Page::getByID($eID); 
$pageLink = $eventPage->cPath;


mysqlt error: [1054: Unknown column 'Array' in 'where clause'] in EXECUTE("select Pages.cID, Pages.pkgID, Pages.cPointerID, Pages.cPointerExternalLink, Pages.cIsActive, Pages.cIsSystemPage, Pages.cPointerExternalLinkNewWindow, Pages.cFilename, Collections.cDateAdded, Pages.cDisplayOrder, Collections.cDateModified, cInheritPermissionsFromCID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cCheckedOutUID, cIsTemplate, uID, cPath, cParentID, cChildren, cCacheFullPageContent, cCacheFullPageContentOverrideLifetime, cCacheFullPageContentLifetimeCustom from Pages inner join Collections on Pages.cID = Collections.cID left join PagePaths on (Pages.cID = PagePaths.cID and PagePaths.ppIsCanonical = 1) where Pages.cID = Array")
Remo replied on at Permalink Best Answer Reply
Remo
I can't tell you much since your code is incomplete. The theory: You're calling fetchRow which returns an array but Page::getByID expects a discrete value - a number..

Without knowing where $callIDs comes from, something like this could work:

$eID = $calIDs->fetchRow(); 
$eventPage = Page::getByID($eID['cID']); 
$pageLink = $eventPage->cPath;
jhart replied on at Permalink Reply
you sir, are the man!

gracias
Remo replied on at Permalink Reply
Remo
de nada!