Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Standardy tworzenia stron[?]
vir_e
post
Post #1





Grupa: Zarejestrowani
Postów: 55
Pomógł: 1
Dołączył: 25.03.2008

Ostrzeżenie: (0%)
-----


Witam, mam takie pytanko... niedawno skończyłem swoją pierwsza stronę w php oparta o mysql i korzystałem z dostępnej klasy templatowej w moim kursie php.
  1. <?php
  2. class cTemplate
  3. {
  4. var $assign;
  5. var $parsed;
  6.  
  7. function parse ($_file_name)
  8. {
  9. if (!file_exists($_file_name))
  10. {
  11. echo &#092;"Nie znaleziono pliku: \".$_file_name;
  12. return 0;
  13. }
  14.  
  15. $this->parsed = file_get_contents($_file_name, 500000);
  16.  
  17. $i = 0;
  18. if (isset($this->assign))
  19. {
  20. foreach ($this->assign as $key => $value)
  21. {
  22. $source[$i] = &#092;"{$\".$key.\"}\";
  23. $destination[$i] = $value;
  24. $i++;
  25. }
  26. }
  27.  
  28. if (!isset($source)) return $this->parsed; 
  29.  
  30. return $this->parsed = str_replace($source, $destination, $this->parsed);
  31. }
  32. }
  33.  
  34. ?>



i do łączenia się z bazą używałem

  1. <?php
  2. class cTemplate
  3. {
  4. var $assign; 
  5. var $parsed;
  6.  
  7. function parse ($_file_name)
  8. {
  9. if (!file_exists($_file_name))
  10. {
  11. echo &#092;"Nie znaleziono pliku: \".$_file_name;
  12. return 0;
  13. }
  14.  
  15. $this->parsed = file_get_contents($_file_name, 500000);
  16.  
  17. $i = 0;
  18. if (isset($this->assign))
  19. {
  20. foreach ($this->assign as $key => $value)
  21. {
  22. $source[$i] = &#092;"{$\".$key.\"}\";
  23. $destination[$i] = $value;
  24. $i++;
  25. }
  26. }
  27.  
  28. if (!isset($source)) return $this->parsed; 
  29.  
  30. return $this->parsed = str_replace($source, $destination, $this->parsed);
  31. }
  32. }
  33.  
  34. ?>



no ale myślę że ta klasa do łączenia się z bazą to mniej ważna rzecz....



I teraz mam pytanie co do dzisiejszych standardów tworzenia stron w php. Jakie one są? (Pewnie jest ich wiele, ale taki najpopularniejszy?) . Czy korzysta się z "pluginu" SMARTY ( http://pl.wikibooks.org/wiki/PHP/Smarty ) które się doinstalowuje do PHP - i czy są one zainstalowane na większości serwerów ? A do łączenia się z bazą np. bilboteki PDO ( http://pl.wikibooks.org/wiki/PHP/Biblioteka_PDO ).

Chciałbym wiedzieć jak to się dzisiaj robi (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

Ten post edytował vir_e 28.06.2008, 17:02:48
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
vir_e
post
Post #2





Grupa: Zarejestrowani
Postów: 55
Pomógł: 1
Dołączył: 25.03.2008

Ostrzeżenie: (0%)
-----


do łączenia uzywam tego:
  1. <?php
  2. class db_interface
  3. {
  4. var $resource;
  5. var $result;
  6.  
  7. function db_interface($_base_name, $_user, $_pswd, $_host)
  8. {
  9. $this->resource = mysql_connect ($_host, $_user, $_pswd) or die ("polaczenie sie nie powiodlo");
  10. mysql_select_db($_base_name) or die ("wybranie bazy zakonczylo sie niepowodzeniem");
  11. }
  12.  
  13. function query($_query)
  14. {
  15. $this->result = mysql_query($_query) or die ("zapytanie zakonczylo sie niepowodzeniem");
  16. }
  17.  
  18. function get_query($_query)
  19. {
  20. $this->result = mysql_query($_query) or die ("zapytanie zakonczylo sie niepowodzeniem");
  21. $i = 0;
  22. while ($record = mysql_fetch_array($this->result, MYSQL_ASSOC))
  23. {
  24. foreach ($record as $field_name => $field_value)
  25. {
  26. $table[$i][$field_name] = $field_value;
  27. }
  28. $i++;
  29. }
  30. mysql_free_result($this->result);
  31.  
  32. if ($i == 0)
  33. return 0;
  34. else
  35. return $table;
  36. }
  37.  
  38. function close()
  39. {
  40. mysql_close($this->resource);
  41. }
  42.  
  43. }
  44. ?>


zle mi sie skopiowalo (IMG:http://forum.php.pl/style_emoticons/default/guitar.gif)
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: 3.10.2025 - 04:40