|
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 |
Which is best to place at the top? |
Smarty Initialization |
|
0% |
[ 0 ] |
Database Connection |
|
0% |
[ 0 ] |
Irrelevant |
|
100% |
[ 1 ] |
|
Total Votes : 1 |
|
Author |
Message |
NicklasBach Smarty n00b
Joined: 04 Mar 2019 Posts: 1
|
Posted: Mon Mar 04, 2019 6:38 pm Post subject: Database connection or Smarty initialization first? |
|
|
Hello fellow Developers!
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?
Let me be more precise, i case that was to few details.
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?
Thanks in advance! |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Mar 07, 2019 9:08 am Post subject: |
|
|
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 |
|
|
|
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
|