Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26214
Modified Files:
serendipity_functions.inc.php serendipity_db_mysql.inc.php
serendipity_db_postgres.inc.php
Log Message:
bugfix #946493 - postgresql limit error
Index: serendipity_db_mysql.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_db_mysql.inc.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- serendipity_db_mysql.inc.php 11 Nov 2003 16:22:31 -0000 1.16
+++ serendipity_db_mysql.inc.php 5 May 2004 09:14:31 -0000 1.17
@@ -82,6 +82,11 @@
return $start . ', ' . $offset;
}
+function serendipity_db_limit_sql($limitstring)
+{
+ return ' LIMIT ' . $limitstring;
+}
+
function serendipity_db_connect()
{
global $serendipity;
@@ -97,7 +102,7 @@
function serendipity_db_schema_import($query)
{
- static $search = array('{AUTOINCREMENT}', '{PRIMARY}',
+ static $search = array('{AUTOINCREMENT}', '{PRIMARY}',
'{UNSIGNED}', '{FULLTEXT}', '{BOOLEAN}');
static $replace = array('int(11) not null auto_increment', 'primary key',
'unsigned' , 'FULLTEXT', 'enum (\'true\', \'false\') NOT NULL default \'true\'');
Index: serendipity_db_postgres.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_db_postgres.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- serendipity_db_postgres.inc.php 21 Jan 2004 07:24:40 -0000 1.9
+++ serendipity_db_postgres.inc.php 5 May 2004 09:14:31 -0000 1.10
@@ -7,14 +7,14 @@
$serendipity['dbConn'] = pg_connect(
sprintf(
'%sdbname=%s user=%s password=%s',
-
+
strlen($serendipity['dbHost']) ? ('host=' . $serendipity['dbHost'] . ' ') : '',
$serendipity['dbName'],
$serendipity['dbUser'],
$serendipity['dbPass']
)
);
-
+
return $serendipity['dbConn'];
}
@@ -28,6 +28,17 @@
return $offset . ', ' . $start;
}
+function serendipity_db_limit_sql($limitstring)
+{
+ $limit_split = split(',', $limitstring);
+ if (count($limit_split) > 1) {
+ $limit = ' LIMIT ' . $limit_split[1] . ' OFFSET ' . $limit_split[0];
+ } else {
+ $limit = ' LIMIT ' . $limit_split[0];
+ }
+ return $limit;
+}
+
function serendipity_db_affected_rows()
{
global $serendipity;
@@ -94,16 +105,16 @@
{
static $search = array('{AUTOINCREMENT}', '{PRIMARY}', '{UNSIGNED}',
'{FULLTEXT}', '{BOOLEAN}', 'int(1)', 'int(10)', 'int(11)', 'int(4)');
- static $replace = array('SERIAL', 'primary key', '', '', 'BOOLEAN NOT NULL', 'int2',
+ static $replace = array('SERIAL', 'primary key', '', '', 'BOOLEAN NOT NULL', 'int2',
'int4', 'int4', 'int4');
-
+
return serendipity_db_query(str_replace($search, $replace, $query));
}
function serendipity_db_probe($hash, &$errs)
{
global $serendipity;
-
+
$serendipity['dbConn'] = pg_connect(
sprintf(
'%sdbname=%s user=%s password=%s',
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.259
retrieving revision 1.260
diff -u -d -r1.259 -r1.260
--- serendipity_functions.inc.php 3 May 2004 11:05:57 -0000 1.259
+++ serendipity_functions.inc.php 5 May 2004 09:14:28 -0000 1.260
@@ -588,11 +588,7 @@
$limit = (($serendipity['GET']['page']-1)*$limit) . ',' . $limit;
}
- if (strtolower($serendipity['dbType']) == 'postgres') {
- $limit = 'LIMIT ' . join (' OFFSET ', split(',', $limit));
- } else {
- $limit = 'LIMIT '. $limit;
- }
+ $limit = serendipity_db_limit_sql($limit);
}
if (isset($serendipity['GET']['adminModule']) && $serendipity['GET']['adminModule'] == 'entries' && $serendipity['serendipityUserlevel'] < USERLEVEL_CHIEF) {
@@ -1127,11 +1123,7 @@
global $serendipity;
if (!empty($limit)) {
- if (strtolower($serendipity['dbType']) == 'postgres') {
- $limit = 'LIMIT ' . join (' OFFSET ', split(',', $limit));
- } else {
- $limit = 'LIMIT '. $limit;
- }
+ $limit = serendipity_db_limit_sql($limit);
} else {
$limit = '';
}
|