PDA

View Full Version : Postgres error in dir_links.php


drift82
07-12-2005, 05:32 AM
Postgresql does not support the order by 10,5 method of declaring limits and offsets. Hence dir_links.php runs into an error with

$rs = $db->SelectLimit("SELECT L.*, ".$db->IfNull('C.TITLE', "'Top'")." AS CATEGORY FROM {$tables['link']['name']} AS L LEFT OUTER JOIN {$tables['category']['name']} AS C ON L.CATEGORY_ID = C.ID $where ".$orderBy, LINKS_PER_PAGE, LINKS_PER_PAGE * ($page -1));

I fixed it via changing a couple lines

if (defined('SORT_FIELD') && SORT_FIELD != '') {
$orderBy = ' order by '. (SORT_FIELD == 'CATEGORY' ? 'C.TITLE' : 'L.'.SORT_FIELD).' '.SORT_ORDER;
}

$rs = $db->SelectLimit("SELECT L.*, ".$db->IfNull('C.TITLE', "'Top'")." AS CATEGORY FROM {$tables['link']['name']} AS L LEFT OUTER JOIN {$tables['category']['name']} AS C ON L.CATEGORY_ID = C.ID $where ".$orderBy . " limit " . LINKS_PER_PAGE . " offset " . LINKS_PER_PAGE * ($page -1));

If this works with mysql, please update and refrain from the other syntax for us poor postgres users :D

dcb
07-13-2005, 12:15 AM
First of all phpLD is designed to work with a lot more DBMSes than just MySQL and Postgres, but it has only been tested on those and MS SQL and there are quite a few problems in getting the installer to create, but especially upgrade the database on every possible DBMS.

If you look closely to the code there is no place inside phpLD where MySQL LIMIT syntax, or any other DBMS specific syntax is used.
I have no idea why you had that problem since phpLD uses ADOdb for database abstraction and all DBMS specific syntax constructs are handled or simulated by ADOdb.