diff --git a/lib/model/doctrine/Community.class.php b/lib/model/doctrine/Community.class.php index ce7a7a710..8402c60cd 100644 --- a/lib/model/doctrine/Community.class.php +++ b/lib/model/doctrine/Community.class.php @@ -211,16 +211,37 @@ public function preDelete($event) } } - public function joinAllMembers() + public function joinAllMembers() { - $conn = Doctrine::getTable('Member')->getConnection(); - $query = 'SELECT id FROM '.Doctrine::getTable('Member')->getTableName().' m' - . ' WHERE NOT EXISTS (SELECT * FROM '.Doctrine::getTable('CommunityMember')->getTableName().' cm WHERE m.id = cm.member_id AND cm.community_id = ?)' - . ' AND (m.is_active = 1 OR m.is_active IS NULL)'; - $insertIds = $conn->fetchColumn($query, array($this->getId())); - foreach ($insertIds as $memberId) + $pdo = opDoctrineQuery::getMasterConnection()->getDbh(); + $pdo->beginTransaction(); + + $query = <<join($memberId, $this->getId()); + $stmt = $pdo->prepare($query); + $stmt->execute(array('community_id' => $this->id)); + $total = $stmt->rowCount(); + + $pdo->commit(); } + catch (Exception $e) + { + $pdo->rollback(); + + throw $e; + } + + return $total; } }