21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 201 Views |
-
Error in the Group Member function?

29 June 2012 at 2:24am
Hi all,
I have been trying to use the JOIN arguement in the Group->Member() function on a website that has SS version 2.4.5 on it. I think there is a bug in the function.
Shouldn't: -
$join .= " INNER JOIN \"$table\" ON \"$table\".\"MemberID\" = \"Member\".\"ID\"" . Convert::raw2sql($join);
Be: -$join = " INNER JOIN \"$table\" ON \"$table\".\"MemberID\" = \"Member\".\"ID\"" . Convert::raw2sql($join);
i.e. the first one is adding the JOIN twice is it not? I am getting an error until I patch that line and it works fine.
public function Members($limit = "", $offset = "", $filter = "", $sort = "", $join = "") {
$table = "Group_Members";
if($filter) $filter = is_array($filter) ? $filter : array($filter);
if( is_numeric( $limit ) ) {
if( is_numeric( $offset ) )
$limit = "$limit OFFSET $offset";
else
$limit = "$limit OFFSET 0";
} else {
$limit = "";
}
// Get all of groups that this group contains
$groupFamily = implode(", ", $this->collateFamilyIDs());
$filter[] = "\"$table\".\"GroupID\" IN ($groupFamily)";
$join .= " INNER JOIN \"$table\" ON \"$table\".\"MemberID\" = \"Member\".\"ID\"" . Convert::raw2sql($join);
$result = singleton("Member")->instance_get(
$filter,
$sort,
$join,
$limit,
"ComponentSet" // datatype
);
if(!$result) $result = new ComponentSet();$result->setComponentInfo("many-to-many", $this, "Group", $table, "Member");
foreach($result as $item) $item->GroupID = $this->ID;
return $result;
} -
Re: Error in the Group Member function?

30 June 2012 at 12:46pm
With that change isn't it ignore the $join argument completely?
-
Re: Error in the Group Member function?

30 June 2012 at 10:58pm
It doesn't ignore the $join arguement because the $join string is being over written with the Group_Members join string, and then at the end the $join arguement it being added (being run through the convert::raw2sql() function. With .= the raw $join arguement is also being added to the front of the string as well as the converted version at the end.
| 201 Views | ||
|
Page:
1
|
Go to Top |


