Extending the ItemList Class

Permalink 1 user found helpful
So I'm a little confused when it comes to extending the ItemList. I'll try to orient my question so that more people can take advantage of the explanation.

How do you create a simple extension of the DatabaseItemList class, for example, so that it lists mission data from a video game.

Say I have a table named 'Missions' with columns: 'mID', 'date' and 'type'.

I assumed the code should look something like this:
class MissionList extends DatabaseItemList {
   protected $autoSortColumns = array('mID', 'date', 'type');
   protected $itemsPerPage = 10;   
   public function filterByID($mID, $comparison = '=') {
      $this->filter('mID', $mID, $comparison);
   }
   public function filterByType($type) {
      $this->filter('type', $type, '=');
   }
   public function filterByDate($date, $comparison = '=') {
      $this->filter('date', $date, $comparison);
   }
   protected function setBaseQuery() {
      $this->setQuery('SELECT DISTINCT mID, date, type FROM GameMissions ');
   }
However, when I us the following code
$ml = new MissionList();
$ml->debug();
print_r($ml->get());
I get the following error:
(mysql):  where 1=1 limit 0,10    
1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where 1=1 limit 0,10' at line 1
                           ADOConnection._Execute( where 1=1 limit 0,10 , false) % line 1012, file: adodb.inc.php
                        ADOConnection.Execute( where 1=1 limit 0,10 , false) % line 1543, file: adodb.inc.php
                     ADOConnection.GetArray( where 1=1 limit 0,10 , false) % line 1380, file: adodb.inc.php
                  ADOConnection.GetAll( where 1=1 limit 0,10 ) % line    0, file: 
               call_user_func_array(Array[2], Array[1]) % line   73, file: database.php
(mysql): select timestamp, cfValue from Config where cfKey = 'SITE_DEBUG_LEVEL'   
An unexpected error occurred.
mysql error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where 1=1 limit 0,10' at line 1] in EXECUTE(" where 1=1 limit 0,10 ")
What am I doing wrong?

ijessup
 
andrew replied on at Permalink Best Answer Reply
andrew
try renaming your setBaseQuery method to __construct()
ijessup replied on at Permalink Reply
ijessup
Thanks!

That works, but __construct() has to be a public function. I suppose that should be obviously, though. :p