$this->allGroups = array (); // Create an array of group names from the MODx db
$tableName = $modx->getFullTableName('webgroup_names`);
echo "Full Table Name: ".$tableName; // I get the correct table name here
$sql = "SELECT name FROM $tableName";
if ($rs = $modx->db->query($sql)) {
while ($row = $modx->db->getRow($rs)) {
$this->allGroups[] = stripslashes($row['name']);
}
} else {
echo "Query Failed\n"; // this is all I get
print_r($rs); // prints nothing.
}if ($rs = $modx->query("SELECT name FROM {$modx->getTableName('modWebGroup')}")) {
$allGroups= $rs->fetchAll(PDO_FETCH_COLUMN);
}$webgroups= $modx->getCollection('modWebGroup');
foreach ($webgroups as $group) {
$allGroups[]= $group->get('name');
}
First of all, there is no webgroup_names table in Revolution. But if there were:
$sql = "SELECT name FROM $tableName";
$sql = "SELECT name FROM ". $tableName;
It won’t run cause it was theoretical, if web groups still existed. What you want is modUserGroup. Exchange modUserGroup in those queries below and you should get the information. The entire user system was consolidated, so the old table names are no longer valid and the classes for those old tables are there only to help in the migration process that will be added to upgrade installs from legacy MODx releases when we get to beta.
getFullTableName is the deprecated legacy function (as is the entire DBAPI) -- you now want getTableName(), which is an xPDO function inherited by the modX class. And you refer to the name of the class to get the table name. Thus, modUserGroup, not membergroup_names.
Quote from: OpenGeek at Jul 25, 2008, 12:51 PM
It won’t run cause it was theoretical, if web groups still existed. What you want is modUserGroup. Exchange modUserGroup in those queries below and you should get the information. The entire user system was consolidated, so the old table names are no longer valid and the classes for those old tables are there only to help in the migration process that will be added to upgrade installs from legacy MODx releases when we get to beta.
I got that. I had assumed that your first example would run if I used ’membergroup_names’ since it exists and has the information I want.
On second thought, maybe it would have if I had used getFullTableName() instead of getTableName().
$sql = "SELECT name FROM ".$tableName;
if ($rs = $modx->db->query($sql)) {
while ($row = $modx->db->getRow($rs)) {
$this->allGroups[] = stripslashes($row['name']);
}
} else {
echo "Query Failed\n";
return '';
}