PostgreSQL - a few more query compatibility issues (submitted by oxygene)

This commit is contained in:
CiaranG 2009-03-11 23:41:30 +00:00
parent 70d5fc4684
commit c08e4d904e
3 changed files with 9 additions and 3 deletions

View File

@ -119,7 +119,7 @@ class PeopletagAction extends Action
'FROM profile JOIN profile_tag ' . 'FROM profile JOIN profile_tag ' .
'ON profile.id = profile_tag.tagger ' . 'ON profile.id = profile_tag.tagger ' .
'WHERE profile_tag.tagger = profile_tag.tagged ' . 'WHERE profile_tag.tagger = profile_tag.tagged ' .
'AND tag = "%s" ' . "AND tag = '%s' " .
'ORDER BY profile_tag.modified DESC%s'; 'ORDER BY profile_tag.modified DESC%s';
$profile->query(sprintf($qry, $this->tag, $lim)); $profile->query(sprintf($qry, $this->tag, $lim));

View File

@ -65,7 +65,9 @@ class SupAction extends Action
$notice->query('SELECT profile_id, max(id) AS max_id ' . $notice->query('SELECT profile_id, max(id) AS max_id ' .
'FROM notice ' . 'FROM notice ' .
'WHERE created > (now() - ' . $seconds . ') ' . ((common_config('db','type') == 'pgsql') ?
'WHERE extract(epoch from created) > (extract(epoch from now()) - ' . $seconds . ') ' :
'WHERE created > (now() - ' . $seconds . ') ' ) .
'GROUP BY profile_id'); 'GROUP BY profile_id');
$updates = array(); $updates = array();

View File

@ -232,7 +232,11 @@ class Notice extends Memcached_DataObject
$notice = new Notice(); $notice = new Notice();
$notice->profile_id = $profile_id; $notice->profile_id = $profile_id;
$notice->content = $content; $notice->content = $content;
if (common_config('db','type') == 'pgsql')
$notice->whereAdd('extract(epoch from now() - created) < ' . common_config('site', 'dupelimit'));
else
$notice->whereAdd('now() - created < ' . common_config('site', 'dupelimit')); $notice->whereAdd('now() - created < ' . common_config('site', 'dupelimit'));
$cnt = $notice->count(); $cnt = $notice->count();
return ($cnt == 0); return ($cnt == 0);
} }