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

Database connection or Smarty initialization first?

 
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 -> General
View previous topic :: View next topic  

Which is best to place at the top?
Smarty Initialization
0%
 0%  [ 0 ]
Database Connection
0%
 0%  [ 0 ]
Irrelevant
100%
 100%  [ 1 ]
Total Votes : 1

Author Message
NicklasBach
Smarty n00b


Joined: 04 Mar 2019
Posts: 1

PostPosted: Mon Mar 04, 2019 6:38 pm    Post subject: Database connection or Smarty initialization first? Reply with quote

Hello fellow Developers! Very Happy
I am new to smarty and still just learning, which means i have a lot of questions coming to me.
Most of which i can find answers to on google, but i have one, which is yet a mystery.

Do i initialise my database connection or my Smarty initialization first? Cool

Let me be more precise, i case that was to few details. Razz

I have the two following lines in my index.php (first page for new users to get to)
Code:

include("app/functions.php");
require("smartyHeader.php");

functions.php is where i have my DB Connection as follows:
Code:
<?php
session_start();
$host = "******";
$user = "******";
$pass = "******";
$db = "******";

// Create connection
$conn = new mysqli($host, $user, $pass, $db);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Changing the charterset to UTF-8 for ÆØÅ support.
$conn->set_charset("utf8");

// Uncomment for test purposes.
//echo "Connected successfully";
?>


And then my smartyHeader.php which has the following:
Code:
<?php
require './libs/Smarty.class.php';

$smarty = new Smarty;
//$smarty->force_compile = true;
$smarty->debugging = true;
$smarty->caching = false;
//$smarty->cache_lifetime = 120;


Again, which one should be preferred over the other? Smile

Thanks in advance!
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Mar 07, 2019 9:08 am    Post subject: Reply with quote

Does not matter, unless you use database connection to obtain Smarty templates, f.e.
And you should really use PDO and utf8mb4.
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 -> General 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