|
Posted by Jerry Stuckle on 11/22/06 01:07
listerofsmeg01@hotmail.com wrote:
> Hi,
>
> Pretty new to PHP and MySQL.
>
> I have a page on my site that displays a lot of information from
> various tables. Currently I have lots of small PHP wrapper functions
> around SQL queries to get each bit of information. This results in
> maybe 10 queries to display one page, but they are all very small and
> simple, and it keeps the PHP looking nice too as they are simple
> function calls to get each piece of info, which can be called from any
> page in my site.
>
> However, after reading up on SQL a bit, I am wondering whether I should
> be looking at just generating one large query at the start, and using
> joins etc to lump all the relevant info together. This complicates the
> PHP as this means a custom query for each page of my site depending on
> what needs to be displayed, but I am wondering if it is worth it if I
> get a fair performance gain.
>
> Can any gurus point me in the right direction? Is there a "proper" way
> to do this sort of thing?
>
> Many thanks.
>
That's what relational databases are all about - having related data in
different tables and joining them together.
Sure you'll have different queries on different pages. That's because
you need different data on different pages, don't you? The rest of your
code isn't the same - why should the queries be?
Let the database do what it's best at!
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|