From 81e6d50c533964899308e5745745381c340a1764 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 22 Jul 2008 12:15:49 -0400 Subject: blow off DB_DataObject joins, write SQL from scratch darcs-hash:20080722161549-84dde-fedeed101bdef172f4a7aabf2278f1a2277a6d88.gz --- classes/User.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'classes') diff --git a/classes/User.php b/classes/User.php index 1772b82e0..4f46653e4 100644 --- a/classes/User.php +++ b/classes/User.php @@ -128,23 +128,17 @@ class User extends DB_DataObject return true; } - - function noticesWithFriends() { + + function noticesWithFriends($offset=0, $limit=20) { $notice = new Notice(); - $notice->selectAs(); - - $subscription = new Subscription(); + $notice->query('SELECT notice.* ' . + 'FROM notice JOIN subscription on notice.profile_id = subscription.subscribed' . + 'WHERE subscription.subscriber = ' . $this->id . + 'ORDER BY created DESC, notice.id DESC ' . + 'LIMIT ' . $offset . ', ' . $limit); - $subscription->subscriber = $this->id; - - $notice->joinAdd($subscription); - $notice->whereAdd('notice.profile_id = subscription.subscribed'); - $notice->selectAs($subscription, 'sub_%'); - - $notice->orderBy('created DESC, notice.id DESC'); - return $notice; } } -- cgit v1.2.3-54-g00ecf