Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Foreach Array voller Objekte

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
obscur3
Smarty Rookie


Joined: 01 Sep 2012
Posts: 5

PostPosted: Sat Sep 01, 2012 7:23 pm    Post subject: Foreach Array voller Objekte Reply with quote

Guten Abend,

nachdem ich seid ungefähr 2 Stunden angestrengt versuche herauszufinden, wie ich ein Array voller Objekte mithilfe von {foreach} ausgebe, habe ich aufgegeben und ziehe nun euch zu rate (:

Dies ist der Ausschnitt aus dem Template und hier liegt wahrscheinlich auch der Fehler
Code:

{foreach $cars as $car}
    <li>{$car->producer} {$car->name}</li>
{/foreach}


und so übergebe ich die Objekte:
Code:
$smarty->assign('cars', $cars->all());


$cars->all gibt das aus:
Code:

function all() {
       $statement = $this->db->prepare("select * from cars");
       $statement->execute();
       $result = array();
       foreach ($statement as $row) {
            $result[] = new Car($row);
       }
       return $result;
     }


Mein Grundaufbau stimmt , es geht mir nur um den Zugriff. Das Array gibt auch die Daten aus , die ich haben möchte , das habe ich schon getestet.

Ich hoffe ihr könnt mir schnell helfen und jetzt schon mal vielen Dank im Vorraus!

lg obscur3
Back to top
View user's profile Send private message
obscur3
Smarty Rookie


Joined: 01 Sep 2012
Posts: 5

PostPosted: Sun Sep 02, 2012 11:17 am    Post subject: Reply with quote

Kann mir niemand helfen ? Ich werde mal im englischen Bereich posten. :/
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sun Sep 02, 2012 1:10 pm    Post subject: Reply with quote

Siehe http://www.smarty.net/forums/viewtopic.php?t=22953

Bitte immer die Fehlermeldungen mit Posten...
Back to top
View user's profile Send private message
obscur3
Smarty Rookie


Joined: 01 Sep 2012
Posts: 5

PostPosted: Sun Sep 02, 2012 1:17 pm    Post subject: Reply with quote

Alles klar. gemerkt für nächste Mal. Vielen Dank für die Antwort. Es hat alles geklappt!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP