Dotclear

Changeset 2316:f8620977a163 for inc


Ignore:
Timestamp:
10/09/13 06:44:16 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Revamp query for PostgreSQL in order to use DISTNICT ON rather than GROUP BY, in getPosts(), addresses #989

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.blog.php

    r2315 r2316  
    775775          elseif (!empty($params['sql_only']))  
    776776          { 
    777                $strReq = 'SELECT P.post_id '; 
     777               if ($this->core->con->driver() == 'pgsql' && isset($params['media'])) { 
     778                    $strReq = 'SELECT DISTINCT ON (P.post_id) P.post_id '; 
     779               } else { 
     780                    $strReq = 'SELECT P.post_id '; 
     781               } 
    778782          } 
    779783          else 
     
    791795               } 
    792796                
    793                $strReq = 
    794                'SELECT P.post_id, P.blog_id, P.user_id, P.cat_id, post_dt, '. 
     797               if ($this->core->con->driver() == 'pgsql' && isset($params['media'])) { 
     798                    $strReq = 'SELECT DISTINCT ON (P.post_id) '; 
     799               } else { 
     800                    $strReq = 'SELECT '; 
     801               } 
     802               $strReq .= 
     803               'P.post_id, P.blog_id, P.user_id, P.cat_id, post_dt, '. 
    795804               'post_tz, post_creadt, post_upddt, post_format, post_password, '. 
    796805               'post_url, post_lang, post_title, '.$content_req. 
     
    958967          } 
    959968           
    960           if (!$count_only && isset($params['media'])) { 
     969          if ($this->core->con->driver() != 'pgsql' && !$count_only && isset($params['media'])) { 
    961970               $strReq .= ' GROUP BY P.post_id '; 
    962971          } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map