Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Smarty i obiekty
ganimedes
post
Post #1





Grupa: Zarejestrowani
Postów: 66
Pomógł: 0
Dołączył: 1.04.2004

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


Przykładowo mam taką tablice z objektami
  1. <?
  2. (
  3. [items_list] => Array
  4. (
  5. [0] => NewsModel Object
  6. (
  7. [0] => 6
  8. [news_id] => 6
  9. [1] => 1
  10. [user_id] => 1
  11. [2] => topic 1
  12. [topic] => topic 1
  13. [3] => short_content 1
  14. [short_content] => short_content 1
  15. [4] => content 1
  16. [content] => content 1
  17. [5] => 2004-12-24 13:56:15
  18. [date] => 2004-12-24 13:56:15
  19. [6] => n
  20. [approved] => n
  21. )
  22.  
  23. [1] => NewsModel Object
  24. (
  25. [0] => 7
  26. [news_id] => 7
  27. [1] => 2
  28. [user_id] => 2
  29. [2] => topic 2
  30. [topic] => topic 2
  31. [3] =>short_content 2
  32. [short_content] => short_content 2
  33. [4] => content 2
  34. [content] => content 2
  35. [5] => 2004-12-24 13:56:15
  36. [date] => 2004-12-24 13:56:15
  37. [6] => n
  38. [approved] => n
  39. )
  40. )
  41.  
  42. )
  43.  
  44. ?>

i jak ją wyświetlić w smarty?? Proshe tylko nie odsyłać mnie do innych stron bo dopiero zaczynam używać klase smarty...

Metody ktore użyłem
  1. <?
  2. public function news(){
  3. $query = &#092;"SELECT * FROM news\";
  4. $result = $this->_connection->query($query);
  5. $result_arr = array();
  6. while ($line = $result->fetchArray() ){
  7. $result_arr[] = new NewsModel($line);
  8. }
  9.  return $result_arr;
  10. }
  11.  
  12. // class newsmodel
  13.  
  14. <?php
  15. class NewsModel{ 
  16. public function __construct($data_array){ 
  17. foreach ($data_array as $k => $v){
  18. $this->$k = $v;
  19. }
  20. }
  21. }
  22. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 21.08.2025 - 03:37