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

Enviar datos de array PDO

 
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: Spanish
View previous topic :: View next topic  
Author Message
piropeator
Smarty Rookie


Joined: 31 Oct 2007
Posts: 26

PostPosted: Tue Dec 15, 2015 8:13 pm    Post subject: Enviar datos de array PDO Reply with quote

Hola a todos. Mi consulta es la siguiente:

En la plantilla tengo:
Code:
{section name=i loop=$lista}
<tr>
      <td>{$lista[i]->codVO}</td>         
      <td>{$lista[i]->nomVO}</td>
</tr>
{assign var="sum" value=$sum+$lista[i]->canVO}
{/section}


La consulta sale de :
Code:
$db = new ConexionDB();
$statement = $db->query('SELECT codigo, nombres FROM prueba');
return $statement->fetchAll(PDO::FETCH_ASSOC);


El fetchAll genera ya un array, pero como asigno los registros a mi objeto VO pues en la plantilla necesito el índice.

Antes lo hacía así:
Code:

$lista = array();
while($fila=$recordSet->FetchRow()) {
$lista[] = new PruebaVO($fila['codigo'], $fila['nombres']);

Pero con el PDO el array ya está generado.
Gracias.
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: Spanish 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