Hello all,
I am working on setting up an external login system for a group of sites that will use an external database. I have everything working on the front end of the site. The issue I am having is getting the list of members for the site into a section in the admin. I have the menu item created and the Member object, my issue is getting the results to show in the gridfield. I have returned the data in an ArrayList and I can export the values properly but they do not align with the $db fields. I then switched to the DataList and have had issued getting data in place. If I add a where clause I get an sql error
[User Error] Couldn't run query: SELECT DISTINCT count(DISTINCT "ExternalLoginMembers"."ID") AS "0" FROM "ExternalLoginMembers" WHERE ("RegisteredSite" = mysite) Unknown column 'RegisteredSite' in 'where clause'
I have my code for now below if anyone can help point me in the right direction. Thanks in advance.
/* Admin */
class ExternalLoginAdmin extends ModelAdmin {
public static $managed_models = array('ExternalLoginMembers');
static $url_segment = 'members';
static $menu_title = 'Members';
static $menu_priority = -1;
/*
* Get Member listing
*/
function getList() {
$members = new externalLogin();
$sitemem = $members->getSiteMembers($_SERVER['HTTP_HOST']);
return $sitemem;
}
}
/*Members*/
class ExternalLoginMembers extends DataObject {
static $db = array(
'Username' => 'Varchar',
'FirstName' => 'Varchar',
'LastName' => 'Varchar',
'StreetAddress' => 'Varchar',
'AptSuiteFloor' => 'Varchar',
'City' => 'Varchar',
'State' => 'Varchar',
'Zip' => 'Varchar',
'Gender' => 'Varchar',
'DateOfBirth' => 'Date',
'EmailAddress' => 'Varchar',
'RegisteredDate' => 'Varchar'
);
/**/
static $searchable_fields = array(
'Username',
'FirstName',
'LastName',
'Gender'
);
/**/
static $summary_fields = array(
'Username' => 'Username',
'FirstName' => 'First Name',
'LastName' => 'Last Name',
'StreetAddress' => 'Street Address',
'AptSuiteFloor' => 'Apt/Suite/Floor',
'City' => 'City',
'State' => 'State',
'Zip' => 'Zip',
'Gender' => 'Gender',
'DateOfBirth' => 'Date Of Birth',
'EmailAddress' => 'Email Address',
'RegisteredDate' => 'Date Registered'
);
/* My External Login Class function */
function getSiteMembers($site) {
global $databaseConfig, $databaseConfig2;
//USE OUR DB
DB::connect($databaseConfig2);
$dos = DataList::create('ExternalLoginMembers');
//BACK TO SILVERSTRIPE DB
DB::connect($databaseConfig);
return $dos;
}