|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
piropeator Smarty Rookie
Joined: 31 Oct 2007 Posts: 26
|
Posted: Tue Dec 15, 2015 8:13 pm Post subject: Enviar datos de array PDO |
|
|
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 |
|
|
|
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
|