Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CommentsManager
- {
- const USER = 'root';
- const PASS = '';
- const DATABASE = 'colina';
- const SERVER = 'localhost';
- private $_conection;
- private static function connect()
- {
- $this->_conection = mysql_connect(
- self::SERVER,
- self::USER,
- self::PASS
- );
- mysql_select_db(
- self::DATABASE,
- $this->_conection
- );
- }
- private static function disconnect()
- {
- mysql_close($this->_conection);
- }
- private static function getComments($sql)
- {
- self::connect();
- $result = mysql_query($sql, $this->_conection);
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
- $all[] = $row;
- }
- self::disconnect();
- return $all;
- }
- public static function buildComments()
- {
- $t = Template::getInstance();
- $t->set_block( '_COMENTARIOS', '_BLK_COMMENTS','TPL_COMMENTS_ITEMS' );
- $sql = "SELECT nombre_visita,fecha_visita,comentario_visita FROM 'visitas'";
- foreach (self::getComments($sql) as $item) {
- $t->set_var("TPL_COMMENT_NAME", $item['nombre_visita']);
- $t->set_var("TPL_COMMENT_DATE", $item['fecha_visita']);
- $t->set_var("TPL_COMMENT_BODY", $item['comentario_visita']);
- $t->parse( 'TPL_COMMENTS_ITEMS', '_BLK_COMMENTS', 1) ;
- }
- $t->parse('TPL_COMMENTS','_COMENTARIOS');
- }
- }
Add Comment
Please, Sign In to add comment