Przykładowo mam taką tablice z objektami
<?
(
(
[0] => NewsModel Object
(
[0] => 6
[news_id] => 6
[1] => 1
[user_id] => 1
[2] => topic 1
[topic] => topic 1
[3] => short_content 1
[short_content] => short_content 1
[4] => content 1
[content] => content 1
[5] => 2004-12-24 13:56:15
[date] => 2004
-12
-24 13
:56
:15
[6] => n
[approved] => n
)
[1] => NewsModel Object
(
[0] => 7
[news_id] => 7
[1] => 2
[user_id] => 2
[2] => topic 2
[topic] => topic 2
[3] =>short_content 2
[short_content] => short_content 2
[4] => content 2
[content] => content 2
[5] => 2004-12-24 13:56:15
[date] => 2004-12-24 13:56:15 [6] => n
[approved] => n
)
)
)
?>
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
<?
public function news(){
$query = \"SELECT * FROM news\";
$result = $this->_connection->query($query);
while ($line = $result->fetchArray() ){
$result_arr[] = new NewsModel($line);
}
return $result_arr;
}
// class newsmodel
<?php
class NewsModel{
public function __construct($data_array){
foreach ($data_array as $k => $v){
$this->$k = $v;
}
}
}
?>