Changeset 4589 for branches


Ignore:
Timestamp:
06/07/11 13:52:50 (13 years ago)
Author:
diogenesduarte
Message:

Ticket #1980 - substituindo a query para pegar o total de linhas por um count(*)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/news_admin/inc/class.sonews.inc.php

    r49 r4589  
    4444 
    4545                        $sql = 'SELECT * FROM phpgw_news WHERE news_cat ' . $filter; 
     46                        $sql_count = 'SELECT count(*) as total FROM phpgw_news WHERE news_cat ' . $filter; 
    4647                        if($activeonly) 
    4748                        { 
    4849                                $now = time(); 
    49                                 $sql .= " AND news_begin<=$now AND news_end>=$now"; 
     50                                $filter_plus = " AND news_begin<=$now AND news_end>=$now"; 
     51                                $sql .= $filter_plus; 
     52                                $sql_count.= $filter_plus; 
    5053                        } 
    5154                        $sql .= $ordermethod; 
    5255 
    53                         $this->db->query($sql,__LINE__,__FILE__); 
    54                         $total = $this->db->num_rows(); 
     56                        $this->db->query($sql_count,__LINE__,__FILE__); 
     57                        if($this->db->next_record()) 
     58                                $total = $this->db->f('total'); 
     59                        else 
     60                                $total=0; 
    5561                        $this->db->limit_query($sql,$start,__LINE__,__FILE__,$limit); 
    5662 
Note: See TracChangeset for help on using the changeset viewer.