I am trying to get a list of connections programmatically.
It is fairly simple:
$query->select('c.id, c.user_id, c.firstname, c.middlename, c.lastname, c.avatar, c.avatarapproved, c.approved, c.confirmed, c.cbactivation, c.banned, c.cb_state, u.email, u.username, c.city, c.state')
->from('`#__comprofiler_members` m')
->leftjoin('`#__comprofiler` c ON c.id = m.referenceid')
->leftjoin('`#__users` u ON u.id = c.user_id');
$query->where('c.banned = 0');
$query->where('m.pending = 0');
$query->where('m.accepted = 1');
$query->where('m.memberid = '.$id);
$query->where('c.approved = 1');
$query->where('c.confirmed = 1');
Is there an existing 'connections' class I can use?
I ask because this is giving me an incorrect result.
The above query give me 3 user records.
If I go to 'connection manager', I get 2 records.
My query must not be correct.
I just can't see what other condition is restricting the results in connection manager to only users 46 and 47.
If there was a 'connections' class I could use, this would solve the problem. The connections class would all ready have all the conditions in the selection... I would assume.
Here is the data from the members table (user 45 is not showing up in the connection manager):
(`referenceid`, `memberid`, `accepted`, `pending`, `membersince`, `reason`, `description`, `type`)
(45, 43, 1, 0, '2012-03-10', '', NULL, NULL),
(43, 45, 1, 0, '2012-03-10', '', '', ''),
(47, 43, 1, 0, '2012-03-19', '', NULL, NULL),
(43, 47, 1, 0, '2012-03-19', '', '', ''),
(46, 43, 1, 0, '2012-03-19', '', 'some comment', 'Family'),
(43, 46, 1, 0, '2012-03-19', '', '', '');
Here are the 3 users:
(`id`, `user_id`, `firstname`, `middlename`, `lastname`, `hits`, `message_last_sent`, `message_number_sent`, `avatar`, `avatarapproved`, `approved`, `confirmed`, `lastupdatedate`, `registeripaddr`, `cbactivation`, `banned`, `banneddate`, `unbanneddate`, `bannedby`, `unbannedby`, `bannedreason`, `acceptedterms`, `website`, `location`, `occupation`, `interests`, `company`, `address`, `city`, `state`, `zipcode`, `country`, `phone`, `fax`)
(45, 45, 'Sanual', NULL, 'Sarphati', 10, '0000-00-00 00:00:00', 0, '', 1, 1, 1, '2012-02-27 09:18:07', '2.25.51.63', '', 0, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 'SLO', NULL, NULL, 'Austria', NULL, NULL)
(46, 46, 'Sandra', NULL, 'Rio', 1, '0000-00-00 00:00:00', 0, '', 1, 1, 1, '2012-03-19 07:55:17', '212.41.200.53', '', 0, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 'Innsbruck', NULL, NULL, 'Austria', NULL, NULL)
(47, 47, 'Tamara', NULL, 'Jones', 1, '0000-00-00 00:00:00', 0, '', 1, 1, 1, '2012-03-19 07:55:17', '86.160.206.168', '', 0, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 'London', NULL, NULL, 'United Kingdom', NULL, NULL);