php - SilverStripe SQL boolean value syntax error -
i trying return sql query code below. reason boolean values i'm trying filter ('showonhomepage' , 'published') throwing following syntax error due question mark placeholder.
you have error in sql syntax; check manual corresponds >your mysql server version right syntax use near '?) , ("dummycontentone"."showonhomepage" = ?)) "dummycontentone" union (s' @ line 5
public function getsitecontent() { if($this->_contentlist!=false) { return $this->_contentlist; } $request = (controller::has_curr() ? controller::curr()->getrequest() : null); $start = round(($request ? intval($request->getvar('start')) : 0)); $dummycontentone = dummycontentone::get()->filter('published', true)->filter('showonhomepage', true)->dataquery()->query()->setorderby(null); $dummycontenttwo = dummycontenttwo::get()->filter('published', true)->filter('showonhomepage', true)->dataquery()->query()->setorderby(null); $this->fixquerycolumns($dummycontentone, $dummycontenttwo); $db = db::query( 'select * '. 'from ('.$dummycontentone->sql().') "dummycontentone" '. 'union ('.$dummycontenttwo->sql().') '. 'order "date" desc, "created" desc '. 'limit '.$this->config()->item_count.' offset '.$start ); // merge array list $list = new arraylist(); foreach($db $row) { $classname=$row['classname']; $list->push(new $classname($row, false, datamodel::inst())); } // calculate total number of items $totalitems = $dummycontentone->count() + $dummycontenttwo->count(); // convert paginated list $pagedlist=actionpaginatedlist::create($list, $this->link('more-content'), $request) ->setpagelength($this->config()->item_count) ->setpagestart($start) ->settotalitems($totalitems) ->setlimititems(false); return $pagedlist; } ... private function fixquerycolumns() { $queries = func_get_args(); $columns = array(); // debug::show($queries); // of columns each query foreach($queries $query) { $columns = array_merge($columns, array_keys($query->getselect())); } ...
any ideas cause this?
i'm using ss3.2
thanks
Comments
Post a Comment