Example #1
0
function set_link($page_sum)
{
    global $global, $smarty;
    $global['page'] = num_bound(1, $page_sum, $global['page']);
    $smarty->assign('page_sum', $page_sum);
}
Example #2
0
 public function get_sheet()
 {
     $this->db->sql_query($this->get_sql());
     $record_count = $this->db->get_record_count();
     if ($record_count > 0) {
         $this->db->set_page_size($this->page_size);
         if ($record_count % $this->page_size > 0) {
             $this->page_sum = intval($record_count / $this->page_size) + 1;
         } else {
             $this->page_sum = intval($record_count / $this->page_size);
         }
         $this->page = num_bound(1, $this->page_sum, $this->page);
         $this->db->set_absolute_page($this->page);
         $record_count = $record_count - ($this->page - 1) * $this->page_size;
         if (!$this->page_size || $record_count < $this->page_size) {
             $this->page_size = $record_count;
         }
         $this->db->set_real_page_size($this->page_size);
         if ($this->field != '*') {
             $arr = explode(',', $this->field);
         } else {
             $arr = explode(',', $this->db->get_all_fields());
         }
         for ($i = 0; $i < $this->page_size; $i++) {
             for ($j = 0; $j < count($arr); $j++) {
                 $field = $arr[$j];
                 $this->data[$i][$field] = $this->deal($field, $this->db->sql_result($i, $field));
             }
         }
     } else {
         $this->page_size = 0;
     }
     return $this->data;
 }