[nycphp-talk] Query to Array and Array loop performance hit.

Mark Armendariz nyphp at
Mon May 26 15:40:55 EDT 2003

You're the man, Hans.  Thank You.

-----Original Message-----
From: Hans Zaunere [mailto:zaunere at] 
Sent: Monday, May 26, 2003 2:13 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Query to Array and Array loop performance hit.

Happy Monday!  :)

--- Mark Armendariz <nyphp at> wrote:
> Good Morning and Happy Sunday New Yorkers (and good day to everyone 
> else)...
> I'm currently working on a project with a designer, and I'm trying to 
> do my very best to keep my code as clean and out of his way as 
> possible. So basically I'm putting all my queries and all the good 
> creamy filling up on top, and then keeping all php code to a minimum 
> on the bottom, when he can rock the design.  I try to to this as much 
> as possible as is, but I always worry about performance (primary wrory

> based on this question).
> Clean code, check.  Queries and logic up top, check.  Output 
> formatting... gets a bit sticky.  The primary issue I have is 
> formatting.  For instance, to keep the code clean down below, I format

> columns for the designer.  For instance, I format all date fields for 
> him, concat all vars for him (I know I can use mysql concat, but that 
> doesn't solve all var issues), and whatever other logic might be 
> necessary.  Since this is part of a outputted query loop, I can't 
> quite put all that logic up top.
> So, to me, the obvious answer would be to loop through the returned 
> array (from the query) up top, format all the columns into a separate 
> array and then in the actaul doc, run a nice and neat foreach to loop 
> through the formatted array.  So my questions are:
> How badly would that hurt page response time?
> Is that just too much work for each page load?

This, to me atleast, is a common practice.  I like to do as much string
manipulation in MySQL as possible, but unless you have tons of data
being loaded, or very heavy traffic, you should have no problem
However, if either of these is an issue, you may want to look at some
type of cacheing.  

> Is there another viable solution (outside of templates - i've used 
> them and I tend to avoid them)?

Templates wouldn't help here - the data still needs to get fetched and
managed.  Just write clean code, paying attention to performance tweaks
where possible.


> Thanks, and have a great Sunday!!!
> Mark Armendariz

--- Unsubscribe at ---

More information about the talk mailing list