Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30634
Modified Files:
serendipity_functions.inc.php
serendipity_admin_comments.inc.php
Log Message:
postgre sql compatibility fixes from Ilya A. Volynets-Evenbakh
Index: serendipity_admin_comments.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_comments.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- serendipity_admin_comments.inc.php 3 Aug 2004 18:05:54 -0000 1.10
+++ serendipity_admin_comments.inc.php 9 Aug 2004 10:00:22 -0000 1.11
@@ -127,14 +127,13 @@
$linkNext = '<input type="button" name="serendipity[nextpage]" value=">>>" disabled="disabled" />';
}
-
+$limit=serendipity_db_limit_sql(($page-1)*$commentsPerPage .",". $commentsPerPage);
$sql = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']}comments c
LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)
WHERE type = 'NORMAL'
". $and ."
" . (($serendipity['serendipityUserlevel'] != USERLEVEL_ADMIN) ? 'AND e.authorid = ' . $serendipity['authorId'] : '') . "
- ORDER BY id DESC
- LIMIT ". ($page-1)*$commentsPerPage .",". $commentsPerPage);
+ ORDER BY id DESC $limit");
if (!is_array($sql)) {
echo NO_COMMENTS;
return;
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.390
retrieving revision 1.391
diff -u -d -r1.390 -r1.391
--- serendipity_functions.inc.php 9 Aug 2004 09:49:54 -0000 1.390
+++ serendipity_functions.inc.php 9 Aug 2004 10:00:22 -0000 1.391
@@ -736,12 +736,14 @@
}
if (strtolower($serendipity['dbType']) == 'postgres') {
- $group = 'DISTINCT ON (e.id)';
+ $group = '';
+ $distinct = 'DISTINCT';
} else {
- $group = 'GROUP BY e.id';
+ $group = 'GROUP BY e.id';
+ $distinct = '';
}
- $query = "SELECT
+ $query = "SELECT $distinct
e.id,
e.title,
e.timestamp,
@@ -922,12 +924,14 @@
global $serendipity;
if (strtolower($serendipity['dbType']) == 'postgres') {
- $group = 'DISTINCT ON (e.id)';
+ $group = '';
+ $distinct = 'DISTINCT';
} else {
- $group = 'GROUP BY e.id';
+ $group = 'GROUP BY e.id';
+ $distinct = '';
}
- $querystring = "SELECT
+ $querystring = "SELECT $distinct
e.id,
e.author,
a.username,
@@ -1471,12 +1475,14 @@
}
if (strtolower($serendipity['dbType']) == 'postgres') {
- $group = 'DISTINCT ON (co.id)';
+ $group = '';
+ $distinct = 'DISTINCT';
} else {
- $group = 'GROUP BY co.id';
+ $group = 'GROUP BY e.id';
+ $distinct = '';
}
- $query = "SELECT
+ $query = "SELECT $distinct
co.id,
co.entry_id, co.timestamp, co.title, co.email, co.url, co.ip, co.body, co.type, co.subscribed,
co.author AS username,
@@ -1516,7 +1522,8 @@
$query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id=$id AND type = 'TRACKBACK' $and ORDER BY id";
if (isset($limit)) {
- $query .= " LIMIT $limit";
+ $limit = serendipity_db_limit_sql($limit);
+ $query .= " $limit";
}
$comments = serendipity_db_query($query);
@@ -3255,6 +3262,10 @@
function serendipity_displayTopUrlList($list, $limit, $use_links = true) {
global $serendipity;
+ if ($limit){
+ $limit = serendipity_db_limit_sql($limit);
+ }
+
/* HACK */
if (preg_match('/^mysqli?/', $serendipity['dbType'])) {
/* Nonportable SQL due to MySQL date functions,
@@ -3266,14 +3277,14 @@
WHERE day > date_sub(current_date, interval 7 day)
GROUP BY host
ORDER BY total DESC, host
- LIMIT $limit";
+ $limit";
} else {
/* Portable version of the same query */
$query = "SELECT scheme, host, SUM(count) AS total
FROM {$serendipity['dbPrefix']}$list
GROUP BY scheme, host
ORDER BY total DESC, host
- LIMIT $limit";
+ $limit";
}
$rows = serendipity_db_query($query);
@@ -3387,7 +3398,7 @@
return;
}
- $query = "DELETE FORM $serendipity[dbPrefix]entrycat WHERE entryid = $postid";
+ $query = "DELETE FROM $serendipity[dbPrefix]entrycat WHERE entryid = $postid";
serendipity_db_query($query);
$query = "INSERT INTO $serendipity[dbPrefix]entrycat (entryid, categoryid) VALUES ($categories[0], $postid)";
|