diff options
author | Ciaran Gultnieks <ciaran@thurlow.(none)> | 2009-01-26 21:10:32 +0000 |
---|---|---|
committer | Ciaran Gultnieks <ciaran@thurlow.(none)> | 2009-01-30 01:12:58 +0000 |
commit | 53274a6d9347c256430187a22347ca4a0910a395 (patch) | |
tree | b7d412f4a75bf918cdebf31f9341f7c25fe96ffe /classes/User.php | |
parent | a4291d64cea2c9190ef190d85b4a858e111554e2 (diff) |
PostgreSQL - code changes to avoid problems where user table is referenced in ad-hoc queries
Diffstat (limited to 'classes/User.php')
-rw-r--r-- | classes/User.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/classes/User.php b/classes/User.php index b1bae8835..b1c061c18 100644 --- a/classes/User.php +++ b/classes/User.php @@ -338,11 +338,12 @@ class User extends Memcached_DataObject { # 3-way join; probably should get cached - $qry = 'SELECT user.* ' . - 'FROM subscription sub1 JOIN user ON sub1.subscribed = user.id ' . - 'JOIN subscription sub2 ON user.id = sub2.subscriber ' . + $UT = common_config('db','type')=='pgsql'?'"user"':'user'; + $qry = "SELECT $UT.* " . + "FROM subscription sub1 JOIN $UT ON sub1.subscribed = $UT.id " . + "JOIN subscription sub2 ON $UT.id = sub2.subscriber " . 'WHERE sub1.subscriber = %d and sub2.subscribed = %d ' . - 'ORDER BY user.nickname'; + "ORDER BY $UT.nickname"; $user = new User(); $user->query(sprintf($qry, $this->id, $this->id)); |