The Dynamic Duo of PEAR::DB and Smarty
Subject:   No, it does not (rebutal)
Date:   2003-04-24 09:06:48
From:   anonymous2
Response to: No, it does not (rebutal)

Not trying to flame, just a discussion. With that said:

1. K, I probably didn't read your article close enough when you explained the why of it. I personally don't plan on ever using anything besides smarty, hence I thought it was unnecessary. I still do think it's unnecessary, though. For this article, you're reviewing pear & smarty; for this reason I think the use of the extra class for non-smarty template engines is unnecessary...if the article had a broader scope to include other engines (I'm very glad it doesn't), I could see the justification for the class.

2. My personal experience has shown that the number of pages that do NOT require database access in a complicated php application is nearly zero. Because the exception is rare, I prefer to set a global variable if db access will not be necessary. So, for the

if (!$_GLOBALS['_skip_db']) require_once 'db.class.php';

Then, all pages that need db access have:

require_once '';

as their first line and the rare page that does not need db access has:

$_GLOBALS['_skip_db'] = true;
require_once '';

3. From your reply: "It was just supposed to be a simple example, not a best-practice type of article" but from the article "...I will show throughout this article my experiences and best practices in integrating these two amazing libraries."
This is the reason I pointed out the db connection info in each script...the article did mention best practices.

4. IMHO, ideal php applications should use the same fetchmode throughout so maintenance is easier. If you can work on any page in an application and know that it's using an ASSOC fetch mode, you will save a lot of time. Also, if an application does not use the same fetch mode globally than you will need to spend extra time on every edit to check the fetch mode. Personally, I try to code all my applications in such a way that the next person to edit them won't hate me. I think application-wide standards for things like fetch modes is a good way to do that.

5. The syntax for section is not as clean as foreach. It does has some features which foreach does not, but, for basic use, foreach will save you a lot of typing (e.g. foreach does not require you to name the iterator when specifying a specific value in the current loop).


1 to 1 of 1
1 to 1 of 1