php - Reusing MySQL results -
I'm having some theoretical question: I am preparing my own CMS / App Framework (different PHP programmers In the form of the first level ... and always will be) either to create a production ready solution or to develop various modules / plugins which I will use later
However, I have a full connection to the SQL connection I'm thinking of collecting them and then at one place Run:
index.php: & lt ?? Php included ('latestposts .php'); Include ('sidebar.php'); ? & Gt; Latestposts.php: & lt ;? Php function aggregated_data ($ agr) {$ sql = ""; } Function draw ($ data) {...}? & Gt; Sidebar Php: & lt ;? Php function aggregated_data ($ arg) {$ sql = ""; } Function draw ($ data) {...}? & Gt;
Now, while the entire module system application is yet to happen, this idea is already floating somewhere in my brain. However, I am thinking, if I am able to load all the gather_data functions first, run SQL and then run the
Draw
function - and if I use it again I am capable of results!
If, for example, $ sql
is SELECT * POSTS from LIMIT 10
and $ sql2
Choose from Posts Limit 5,
, it is possible to do PHP program to see: "Ah, this is the same SQL, I'll just call it once and reuse the first 5 lines"?
Or is it possible to add this behavior to some DRM?
However, as the tag says, it is still an idea on progress. If this is proven easy to accomplish, then I will post further questions how :)
So, basically: is it possible, is it possible? If both are, then ... any ideas how?
Do not get me wrong, it looks like a simple idea and you're probably running it . But I wonder if it will really be beneficial. Will it create a system faster? Give you more control? Make Development Easier?
I will use a system (or building) using the MVC style coding criteria only by using a good system, create a good DB structure, and get out of the apache (or light pdid). If you decide to make it open source, you will have a much wider acceptance, and if you need a hand with it then another developer can take the right steps and pick up the keyboard.
Also check the query caching in MySQL - You will see the same (though not a one-to-one) profit from caching your query results server side in relation to your query example. Even better, the server is stored in memory, so the PHP / MySQL overhead has been dropped and you do not have to give it a code.
All this one side, I think it is possible. =)
Comments
Post a Comment