Comments on: some notes on php design https://www.nivas.hr/blog/2006/10/28/76/ This is a blog from the Nivas.hr crew to the galaxy of unknown. Fri, 11 Apr 2008 06:52:36 +0000 hourly 1 https://wordpress.org/?v=5.8.2 By: jehutyX https://www.nivas.hr/blog/2006/10/28/76/comment-page-1/#comment-344258 Fri, 11 Apr 2008 06:52:36 +0000 https://www.nivas.hr/blog/2006/10/29/76/#comment-344258 my opinion maybe sounds weird, but why do you all write so serious comments? I mean, do you REALLY think it’s true? Why? What makes you think so? Please share your opinion.

]]>
By: seven https://www.nivas.hr/blog/2006/10/28/76/comment-page-1/#comment-1221 Mon, 20 Nov 2006 08:50:52 +0000 https://www.nivas.hr/blog/2006/10/29/76/#comment-1221 yo metapundit! Thank you very much for the response! Keep up the good work mate, there are many readers of your blog. Our blog has like 5 readers tops! Maybe after redesign we will gain some momentum. :)

]]>
By: metapundit https://www.nivas.hr/blog/2006/10/28/76/comment-page-1/#comment-1134 Sat, 18 Nov 2006 19:14:57 +0000 https://www.nivas.hr/blog/2006/10/29/76/#comment-1134 Hey I’m just happy somebody’s reading the stuff I put out. Checking my referrers and seeing who’s reading and replying is half the fun of blogging… I added a link back to your blog from the article.
-regards
metapundit

]]>
By: seven https://www.nivas.hr/blog/2006/10/28/76/comment-page-1/#comment-1117 Sat, 18 Nov 2006 14:17:52 +0000 https://www.nivas.hr/blog/2006/10/29/76/#comment-1117 Hi Mate,

Thank you a lot for your comment. Cant believe you replied. :) I respect your blog, and read it on day to day basis.

I have to say, that I agree with you on every point. I am in constant search for ways to make my code more maintainable and at the moment, I am not very satisfied with maintainability of my OOP code in php and actionscript (Flash).

But this example is very simple, and using foreach serves it’s purposes.


$row = $db->query('select * from foo');
foreach(array('fname','lname','zip','city','state','street','zip','county') as $field)
$template->setVariable($field,$row[$field]);

But, if you need to do something do data which comes from DB before you set that value to the template, (eg. stripslashes, or htmlencode, or some kind of mathematical stuff) it’s impossible. In that case you will have to use longer syntax. Or you will have to develop template functions and put those primitives inside of template functions. I use smarty, so It’s not much of a problem.

Best regards
Neven

]]>
By: metapundit https://www.nivas.hr/blog/2006/10/28/76/comment-page-1/#comment-1094 Sat, 18 Nov 2006 05:46:28 +0000 https://www.nivas.hr/blog/2006/10/29/76/#comment-1094 Well if you read the article you’ll notice that I don’t actually
recommend the “after” method in the first example. In the second
example, however, the “after” method is not only shorter to type the
first time, it’s much more maintainable. The “before” method requires
you to copy and paste a line (say the bottom one) and then change
“country” to the name of your new field. What are the odds that you
will type

$template->setVariable(‘mynewfield’,$row[‘mynewfeild’]);

See the error? I bet you didn’t immediately. But if you use the
“after” method you only need to add ‘mynewfield’ to the list of column
names… There are of course advantages to succintness other than
maintainability (see Succintness = Power at
http://www.paulgraham.com/power.html ), but I’m basically assuming
people agree about that already…

]]>