BUG: Replaced extendedSQL/buildSQL with DataList as per ticket 8183

BUG: Correcting the4 case of a function

Corrcting the case of a function

BUG: replaced deprecated extendedSQL call with DataList->where
Merge pull request #1126 from silverstripe-rebelalliance/open/8183

BUG: Replaced extendedSQL/buildSQL with DataList as per ticket 8183