Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL] Zamykanie zapytań
marcin0077
post
Post #1





Grupa: Zarejestrowani
Postów: 94
Pomógł: 0
Dołączył: 18.10.2008

Ostrzeżenie: (10%)
X----


Witam

Mam taki kod:

  1. <?php
  2.  
  3. $row = $db->query_first("SELECT COUNT(*) AS itemCount FROM items WHERE isWaiting = '0'");
  4.  
  5. if (!isset($_GET["page"]))
  6. $_GET["page"] = 0;
  7.  
  8. $paginator = getPaginator($row["itemCount"],$_GET["page"],"glowna");
  9.  
  10. $showPerPage = (int)SHOW_PER_PAGE;
  11. $showMe = $_GET["page"]*$showPerPage;
  12. $randAdPlace = rand(2,$showPerPage);
  13.  
  14. $items = $db->query("SELECT *,ite.id,ite.addTime AS addTime, COUNT(comm.cid) AS commNo FROM items AS ite LEFT OUTER JOIN comments AS comm ON comm.picId=ite.id LEFT JOIN users ON (users.uid=ite.uId) WHERE ite.isWaiting = '0' GROUP BY ite.id ORDER BY ite.addTime DESC LIMIT " . $showMe . ", " . $showPerPage);
  15.  
  16. $i = 0;
  17. while ($row = $db->fetch_array($items)) {
  18. $i++;
  19.  
  20. $addClass = ($i < $showPerPage) ? ' morespace' : '';
  21.  
  22. if ($i == $randAdPlace) {
  23. ?>
  24. <div class="contener3">
  25. <div class="advertItems">
  26. <?php
  27. echo getGoogleAd('pub-xxxxxxxxxxxxxx','xxxxxxxxxxxx',336,280,'http://strona.pl/rek/kwadrat.html');
  28. ?>
  29. </div>
  30. </div><br>
  31. <?php
  32. }
  33.  
  34. $preLink = '';
  35. echo '<div class="contener">';
  36. require("includes/item.inc.php");
  37. echo '</div><br>';
  38. }
  39.  
  40. if($i == 0) {
  41. echo @TEXT_PAGE_NULL;
  42. } else {
  43. ?>
  44. <div class="contener2">
  45. <div class="paginator">
  46. <?php
  47. echo getGoogleAd('pub-xxxxxxxxxxxxxxx','xxxxxxxxxx',728,90,'http://strona.pl/rek/jd.html');
  48. echo $paginator;
  49. ?>
  50. </div>
  51. </div>
  52. <?php
  53. }
  54. ?>


i mam pytanie czy te zapytania mysql powinny być jakoś kończone/zamykane - $db->close()?

Ten post edytował marcin0077 15.07.2011, 13:27:26
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 15:59