Mercurial > defr > DualBlog
comparison index.php @ 6:2ea1b19e21f3
Reformatage des requetes, on parcoure toujours l'integralité du recordset.
On respecte maintenant la limite de 80 caractères sur les différentes
requetes d'une part, et on limite directement à 10 le nombre de
post dans la requete de base de façon a ne pas devoir le faire
en PHP ensuite (simplification du code et amelioration des performances).
| author | Franck Deroche <webmaster@defr.org> |
|---|---|
| date | Sat, 20 Oct 2007 17:03:08 +0200 |
| parents | 5bfffcb2624b |
| children | c5bc194d7255 |
comparison
equal
deleted
inserted
replaced
| 5:5bfffcb2624b | 6:2ea1b19e21f3 |
|---|---|
| 10 $nextMonth = $month % 12 + 1; | 10 $nextMonth = $month % 12 + 1; |
| 11 $nextYear = ($month == 12) ? $year+1 : $year; | 11 $nextYear = ($month == 12) ? $year+1 : $year; |
| 12 $Data = new DataAccess; | 12 $Data = new DataAccess; |
| 13 include("top.php"); | 13 include("top.php"); |
| 14 $Data->Connect(); | 14 $Data->Connect(); |
| 15 if($type != "cal") | 15 $query = ($type != 'cal') ? |
| 16 $Data->Query("SELECT * FROM Mess Where num_version='Version 10' ORDER BY num_mess DESC"); | 16 " SELECT * |
| 17 else | 17 FROM Mess |
| 18 $Data->Query("SELECT * FROM Mess WHERE YEAR(DatePost)={$year} AND MONTH(DatePost)={$month} ORDER BY num_mess DESC"); | 18 WHERE num_version='Version 10' |
| 19 $i=0; | 19 ORDER BY num_mess DESC |
| 20 LIMIT 10 | |
| 21 " : " | |
| 22 SELECT * | |
| 23 FROM Mess | |
| 24 WHERE YEAR(DatePost)={$year} AND MONTH(DatePost)={$month} | |
| 25 ORDER BY num_mess DESC | |
| 26 "; | |
| 27 $Data->query($query); | |
| 20 if($type == "cal") { | 28 if($type == "cal") { |
| 21 echo("<div class='cal'>"); | 29 echo("<div class='cal'>"); |
| 22 if($prevYear > $startDate['year'] - 1 || ($prevYear > $startDate['Year'] - 2 && $prevMonth > $startDate['month'] - 1)) | 30 if($prevYear > $startDate['year'] - 1 || ($prevYear > $startDate['Year'] - 2 && $prevMonth > $startDate['month'] - 1)) |
| 23 echo("<a class='calPrev' href='/blog/posts/{$prevYear}/{$prevMonth}'>{$arMonth[$prevMonth - 1]} {$prevYear}</a>"); | 31 echo("<a class='calPrev' href='/blog/posts/{$prevYear}/{$prevMonth}'>{$arMonth[$prevMonth - 1]} {$prevYear}</a>"); |
| 24 else | 32 else |
| 27 echo("<a class='calNext' href='/blog/posts/{$nextYear}/" . ($month % 12 + 1) ."'>{$arMonth[$month%12]} {$nextYear}</a>"); | 35 echo("<a class='calNext' href='/blog/posts/{$nextYear}/" . ($month % 12 + 1) ."'>{$arMonth[$month%12]} {$nextYear}</a>"); |
| 28 else | 36 else |
| 29 echo("<a class='calNext'>{$arMonth[$month%12]} {$nextYear}</a>"); | 37 echo("<a class='calNext'>{$arMonth[$month%12]} {$nextYear}</a>"); |
| 30 echo("{$arMonth[$month - 1]} {$year}</div> "); | 38 echo("{$arMonth[$month - 1]} {$year}</div> "); |
| 31 } | 39 } |
| 32 while(($row=$Data->GetRow()) && ($i++<10 || $type == "cal")) { | 40 while($row=$Data->GetRow()) { |
| 33 $mood = ''; | 41 $mood = ''; |
| 34 $Mess=$Data->utf8_ensure(str_replace("<P>","<p>",str_replace("</P>","</p>", $row['Message']))); | 42 $Mess=$Data->utf8_ensure(str_replace("<P>","<p>",str_replace("</P>","</p>", $row['Message']))); |
| 35 $dateFormatee = strftime("%A %d %B %Y, %Hh%M", strtotime($row['DatePost'])); | 43 $dateFormatee = strftime("%A %d %B %Y, %Hh%M", strtotime($row['DatePost'])); |
| 36 $Titre = $Data->utf8_ensure($row['Titre']); | 44 $Titre = $Data->utf8_ensure($row['Titre']); |
| 37 $Titre_url = str_replace(" ", "_", strip_tags($Titre)); | 45 $Titre_url = str_replace(" ", "_", strip_tags($Titre)); |
