Dotclear

Changeset 2317:d33135045528 for inc


Ignore:
Timestamp:
10/09/13 07:48:15 (12 years ago)
Author:
Dsls
Branch:
default
Message:

removed 1 pgsql dependency in dcBlog, used IN/NOT IN & nested SELECT instead of JOINs to prevent invalid count.

File:
1 edited

Legend:

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

    r2316 r2317  
    775775          elseif (!empty($params['sql_only']))  
    776776          { 
    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                } 
     777               $strReq = 'SELECT P.post_id '; 
    782778          } 
    783779          else 
     
    816812          'LEFT OUTER JOIN '.$this->prefix.'category C ON P.cat_id = C.cat_id '; 
    817813 
    818           if (isset($params['media'])) { 
    819                if ($params['media'] == '0') { 
    820                     $strReq .= 'LEFT OUTER JOIN '.$this->prefix.'post_media M on P.post_id = M.post_id '; 
    821                } else { 
    822                     $strReq .= 'INNER JOIN '.$this->prefix.'post_media M on P.post_id = M.post_id '; 
    823                } 
    824                if (isset($params['link_type'])) { 
    825                     $strReq .= " and M.link_type ".$this->con->in($params['link_type'])." "; 
    826                } 
    827           } 
    828            
    829814          if (!empty($params['from'])) { 
    830815               $strReq .= $params['from'].' '; 
     
    958943           
    959944          if (isset($params['media'])) { 
     945               $strReq .= 'AND P.post_id '; 
    960946               if ($params['media'] == '0') { 
    961                     $strReq .= ' AND M.post_id IS NULL '; 
    962                } 
     947                    $strReq .= 'NOT '; 
     948               } 
     949               $strReq .= 'IN (SELECT M.post_id FROM '.$this->prefix.'post_media M '; 
     950               if (isset($params['link_type'])) { 
     951                    $strReq .= " WHERE M.link_type ".$this->con->in($params['link_type'])." "; 
     952               } 
     953               $strReq .= ")"; 
    963954          } 
    964955 
    965956          if (!empty($params['sql'])) { 
    966957               $strReq .= $params['sql'].' '; 
    967           } 
    968            
    969           if ($this->core->con->driver() != 'pgsql' && !$count_only && isset($params['media'])) { 
    970                $strReq .= ' GROUP BY P.post_id '; 
    971958          } 
    972959 
Note: See TracChangeset for help on using the changeset viewer.

Sites map