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

consulta smarty conexion mysql...

 
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
Fogox
Smarty Rookie


Joined: 09 Apr 2008
Posts: 6

PostPosted: Fri Apr 11, 2008 3:25 pm    Post subject: consulta smarty conexion mysql... Reply with quote

pregunta hay alguna base q use smarty de conexion a mysql_

ejemplo


@mysql_connect('localhost','xxxxxxx','xxxx') or die('No se ha podido conectar el servidor de datos');
@mysql_select_db('xxxx') or die('La base de datos es inexistente');

como puedo reprecentar eso a smarty_

hay q hacer un array >????
uno que se me ocurre ami es

//
$dsn = 'mysql://root:root@localhost/database';$db = DB::connect($dsn);
port

esa es la idea para smarty?

la pregunta seria como declararlo luego para el tpl....

hay alguna pag q explique esto?
saludos
Dante
Back to top
View user's profile Send private message
rocesvinto
Smarty Rookie


Joined: 16 Apr 2008
Posts: 5
Location: Granada, Spain

PostPosted: Wed Apr 16, 2008 8:42 pm    Post subject: Re: consulta smarty conexion mysql... Reply with quote

Dante:
Vamos a ver, no tienes que representar nada de la base de datos, allí solo tienes que mandar los resultados, bien en variables vectoriales, en arrays. Tienes que acostumbrarte a pensar en dos (o más) archivos: el php y el tpl. Verás piensa que estás desarrollando en tres capas:

php es la capa de negocio,
smarty la capa de presentación y
mysql la capa de datos.

.php le da datos al .tpl y se genera la salida que la puedes igualar a una variable (aunque hay otras opciones) y luego te la muestras. algo así.

<?php
.../...
$smarty->assign('variable_en_smarty','Hola esto es una prueba');
$mipaginaquesevea=$smarty->fetch('miplantilla.tpl');
echo $mipaginaquesevea;
?>
y en el tpl
<html><head></head>
<body>{$variable_en_smarty}</body></html>

hay otras muchas formas de provocar la salida del tpl... como...

<?php
.../...
display("laplantillaquesea.tpl");
?>

en fin... no sé si te he sido de mucha ayuda, pero al menos lo he intentado.
Saludos rocesvinto.
Back to top
View user's profile Send private message Visit poster's website
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