Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. class DbData
  2. {
  3.  
  4.     public $page;
  5.     public $total;
  6.    public function getSeoLinks() {
  7.         global $connexion;
  8.         global $total;
  9.         $num = 100;
  10.         $this->page = $_GET['page'];
  11.         $resultats = $connexion->query("SELECT COUNT(*) as count FROM p_recherche_rewrite")->fetch(\PDO::FETCH_ASSOC);
  12.         $this->total = intval(($resultats['count'] - 1) / $num) + 1;
  13.         $this->page = intval($this->page);
  14.         if(empty($this->page) or $this->page < 0) $this->page = 1;
  15.         if($this->page > $this->total) $this->page = $this->total;
  16.         $start = $this->page * $num - $num;
  17.         $sql = "
  18.         SELECT rr.query, rr.rewrite
  19.         FROM p_recherche_rewrite rr
  20.         ORDER BY rr.query ASC
  21.         LIMIT $start, $num
  22.         ";
  23.         $sth = $connexion->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
  24.         $sth->execute();
  25.         while($line = $sth->fetch(PDO::FETCH_ASSOC)) {
  26.             if (is_numeric($line['query'])) {
  27.                 $line['query'] = 'Район' . $line['query'];
  28.             }
  29.             $seoLinks[] = $line;
  30.         }
  31.         return $seoLinks;
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement