From 63ea2b7c451640910d4190c7c0d904af688a85d5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Jun 2009 20:25:52 +1200 Subject: changed to SQL standard of LIMIT 20 OFFSET 1 etc. --- classes/Fave.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Fave.php b/classes/Fave.php index c3ec62dcf..4b28d06b4 100644 --- a/classes/Fave.php +++ b/classes/Fave.php @@ -79,7 +79,7 @@ class Fave extends Memcached_DataObject $qry .= 'ORDER BY modified DESC '; if (!is_null($offset)) { - $qry .= "LIMIT $offset, $limit"; + $qry .= "LIMIT $limit OFFSET $offset"; } $fav->query($qry); -- cgit v1.2.3-54-g00ecf From 1a151ff6f686da198aac72a0adb5001f5d6dcd43 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Jun 2009 22:13:41 +1200 Subject: used SQL standard LIMIT/OFFSET, because every database can understand that --- lib/popularnoticesection.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/popularnoticesection.php b/lib/popularnoticesection.php index e47c9b385..167a6ff8d 100644 --- a/lib/popularnoticesection.php +++ b/lib/popularnoticesection.php @@ -74,11 +74,7 @@ class PopularNoticeSection extends NoticeSection $offset = 0; $limit = NOTICES_PER_SECTION + 1; - if (common_config('db', 'type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; $notice = Memcached_DataObject::cachedQuery('Notice', sprintf($qry, common_config('popular', 'dropoff')), -- cgit v1.2.3-54-g00ecf From 15042ed50b72804eaeefd0c60aa63674bdefe8b4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Jun 2009 10:24:59 +1200 Subject: added user_group.design_id into the group by clause --- lib/groupsbymemberssection.php | 2 +- lib/groupsbypostssection.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/groupsbymemberssection.php b/lib/groupsbymemberssection.php index 963e21f15..ad4884bf8 100644 --- a/lib/groupsbymemberssection.php +++ b/lib/groupsbymemberssection.php @@ -48,7 +48,7 @@ class GroupsByMembersSection extends GroupSection $qry = 'SELECT user_group.*, count(*) as value ' . 'FROM user_group JOIN group_member '. 'ON user_group.id = group_member.group_id ' . - 'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified ' . + 'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified,user_group.design_id ' . 'ORDER BY value DESC '; $limit = GROUPS_PER_SECTION; diff --git a/lib/groupsbypostssection.php b/lib/groupsbypostssection.php index 325b4033f..dc7925d5e 100644 --- a/lib/groupsbypostssection.php +++ b/lib/groupsbypostssection.php @@ -48,7 +48,7 @@ class GroupsByPostsSection extends GroupSection $qry = 'SELECT user_group.*, count(*) as value ' . 'FROM user_group JOIN group_inbox '. 'ON user_group.id = group_inbox.group_id ' . - 'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified ' . + 'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified,user_group.design_id ' . 'ORDER BY value DESC '; $limit = GROUPS_PER_SECTION; -- cgit v1.2.3-54-g00ecf From 403bb38bcd191d7b4e9c62e7f5f4bbb3968729df Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Jun 2009 10:29:02 +1200 Subject: used single quotes in SQL --- classes/Notice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Notice.php b/classes/Notice.php index 08125cf7b..4e244c666 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -873,7 +873,7 @@ class Notice extends Memcached_DataObject if ($cnt > 0) { $qry .= ', '; } - $qry .= '('.$id.', '.$this->id.', '.$source.', "'.$this->created.'") '; + $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') "; $cnt++; if ($cnt >= MAX_BOXCARS) { $inbox = new Notice_inbox(); -- cgit v1.2.3-54-g00ecf From 565dec0e213570b2cad3fa11ec42caf5b52ce1c8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Jun 2009 10:31:31 +1200 Subject: use quote identifiers on the user table --- classes/User_group.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/classes/User_group.php b/classes/User_group.php index 27b444705..b1ab1c2d3 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -275,11 +275,14 @@ class User_group extends Memcached_DataObject // XXX: cache this $user = new User(); + if(common_config('db','quote_identifiers')) + $user_table = '"user"'; + else $user_table = 'user'; $qry = 'SELECT id ' . - 'FROM user JOIN group_member '. - 'ON user.id = group_member.profile_id ' . + 'FROM '. $user_table .' JOIN group_member '. + 'ON '. $user_table .'.id = group_member.profile_id ' . 'WHERE group_member.group_id = %d '; $user->query(sprintf($qry, $this->id)); -- cgit v1.2.3-54-g00ecf From 3722b90a27b2fd53d77c60d51c53cc3e548ffcf9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Jun 2009 10:32:50 +1200 Subject: use single quotes in sql --- lib/grouptagcloudsection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/grouptagcloudsection.php b/lib/grouptagcloudsection.php index 9b7a10f6b..0e0cbdd63 100644 --- a/lib/grouptagcloudsection.php +++ b/lib/grouptagcloudsection.php @@ -73,7 +73,7 @@ class GroupTagCloudSection extends TagCloudSection $quoted = array(); foreach ($names as $name) { - $quoted[] = "\"$name\""; + $quoted[] = "'$name'"; } $namestring = implode(',', $quoted); -- cgit v1.2.3-54-g00ecf From 788dd66dbe75db5d09c0cd5b33bb3347233cbd15 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 Jul 2009 20:23:52 +1200 Subject: add quotes around table named "user" when quote_identifiers is true --- classes/Notice.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 4e244c666..8974e22f8 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -896,10 +896,14 @@ class Notice extends Memcached_DataObject { $user = new User(); + if(common_config('db','quote_identifiers')) + $user_table = '"user"'; + else $user_table = 'user'; + $qry = 'SELECT id ' . - 'FROM user JOIN subscription '. - 'ON user.id = subscription.subscriber ' . + 'FROM '. $user_table .' JOIN subscription '. + 'ON '. $user_table .'.id = subscription.subscriber ' . 'WHERE subscription.subscribed = %d '; $user->query(sprintf($qry, $this->profile_id)); -- cgit v1.2.3-54-g00ecf