Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 135,945 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,747 people online right now. Registration is fast and FREE... Join Now!




i wanna mimic mysql_query function

 
Reply to this topicStart new topic

i wanna mimic mysql_query function

muster_1978
5 May, 2008 - 12:07 AM
Post #1

New D.I.C Head
*

Joined: 4 May, 2008
Posts: 2

Hi Everybody!!!

I have done loads & loads of searching on the net but couldn't find a solution for this.

I have a large bulky code of an application that has been around for years. It is built in PHP/MySql. Now the problem is that as the user database increased...the application slowed down. Now i have been assigned the task to find tune the application to make it faster.

I have parsed through the code and found that there is a function ExecuteSql which takes a query as an argument and then executes that query using mysql_query() function and then returns the result set obtained by running mysql_query().

What i m planning is if i can get the exact structure of the mysql resultset that is returned by executing the mysql_query() function...then i will save that in a flat file. Now whenever i encounter the same identical query again & again..i won't query the database server, instead i will load the result set saved in the flat file and then i will return that result set. In this way i hope that i will b able to make the application faster without doing much changes in this huge bulky code.

Can anybody help me on this?

Would greatly appreciate any help.

Thanks
Muster
User is offlineProfile CardPM
+Quote Post

girasquid
RE: I Wanna Mimic Mysql_query Function
5 May, 2008 - 09:03 AM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,264



Thanked: 14 times
Dream Kudos: 650
My Contributions
It sounds like what you're attempting to implement is something known as caching - and in performance cases, is generally(although not always) a good idea.

One thing you will need to be careful about is what comes back from the query - if you are caching a query that uses ID=1 as an argument and the data has changed, your cache will be invalid - and you'll need to be careful about that.

You might want to take a look at this article on caching for some tips on how to implement it.
User is online!Profile CardPM
+Quote Post

herefishyfishy
RE: I Wanna Mimic Mysql_query Function
5 May, 2008 - 02:43 PM
Post #3

D.I.C Head
Group Icon

Joined: 1 May, 2008
Posts: 60


Dream Kudos: 100
My Contributions
Wait... You want to use flat files to make your code go FASTER? databases are much faster.
User is offlineProfile CardPM
+Quote Post

joeyadms
RE: I Wanna Mimic Mysql_query Function
5 May, 2008 - 04:22 PM
Post #4

D.I.C Head
Group Icon

Joined: 4 May, 2008
Posts: 145



Thanked: 6 times
Dream Kudos: 600
Expert In: PHP, Web Security

My Contributions
Flat Files are used as the cache output, querying a DB has a lot of overhead, takes resources and time, if the page has already been cached, then all you have to do is dump the output to screen.
User is offlineProfile CardPM
+Quote Post

girasquid
RE: I Wanna Mimic Mysql_query Function
5 May, 2008 - 04:28 PM
Post #5

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,264



Thanked: 14 times
Dream Kudos: 650
My Contributions
QUOTE(herefishyfishy @ 5 May, 2008 - 03:43 PM) *

Wait... You want to use flat files to make your code go FASTER? databases are much faster.


I would recommend not making that claim unless you have a lot of benchmarks to back it up with.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:49AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month