[PHP/mySQL] So you wanna design a data driven architecture?

  • bjhess
  • Student
  • Student
  • User avatar
  • Posts: 77
  • Loc: Owatonna, Minnesota

Post 3+ Months Ago

Well, I want to, anyway. As a learning experience, I am creating a mySQL database to archive softball stats. It should work year-to-year, enabling historical stats and what-not.

I have many questions, but I'm going to meter them out as I go. First shot.

How shall I organize my functions?

What I'm imagining here, is needing to create several "transactions" using PHP functions. These will be self contained even to the point of creating a new connection to the DB within the function unless someone points me in a different direction. So I will have a get_roster fuction, I'll have a get_player_stats function, I'll have a get_team_record fuction, and so on.

Does this seem like a legitimate architecture?

The next question for me would be: do I include these on every page? Do I have one file containing each and every one of my transactions or will this bog my load times? I'm imagining that with a shell* page design it really wouldn't matter.

I'm working on the page here. No guarantees what will be there right now as I'm using it for testing - really need to set up a local server for testing. :)

To come: How the heck do I build links/URL to allow ease of development.

*By "shell" page design, I mean a design where all of the layout and menus are built from a base page - same for the whole site - and the only newly loaded stuff on each page is the dynamic content.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Cafu
  • Student
  • Student
  • Cafu
  • Posts: 97

Post 3+ Months Ago

I have a file full of general functions and put functions specific to any page (usually queries) in that page.

My pages don't have any html in them and generally follow this outline:


1) includes
2) check user login/permissions
3) handle POST and GET data, perform functions, include appropriate content pages
4) page specific functions (invariably queries and validation)


You seem to know about application architecture but not about PHP. I'd suggest you do some simple trials with php to get a handle on it before you try to plan out the whole architecture.

Then, I suggest you look into object oriented programming with PHP if you are experienced with it.
  • bjhess
  • Student
  • Student
  • User avatar
  • Posts: 77
  • Loc: Owatonna, Minnesota

Post 3+ Months Ago

Cafu wrote:
I have a file full of general functions and put functions specific to any page (usually queries) in that page.


I assume a general function would be any function used more than once. For instance, I may have a transaction/function to get player information. This could be used on a roster list screen and it may also be used on an individual player screen. I certainly wouldn't want to duplicate code.

I wonder if anyone knows if PHP fuctions, which wouldn't be inherently executed on every page, slow parsing down. Or maybe there is no difference between having 1 function or 100 functions if only 1 function is executed in either case.

Thanks for the other advice. I suppose I could get into OO PHP and then start coding separate tiers - but I do wonder if that is overkill for this application.
  • Cafu
  • Student
  • Student
  • Cafu
  • Posts: 97

Post 3+ Months Ago

Quote:
I wonder if anyone knows if PHP fuctions, which wouldn't be inherently executed on every page, slow parsing down. Or maybe there is no difference between having 1 function or 100 functions if only 1 function is executed in either case.


That's a good question, and I haven't been able to google up much information on it.

From what I have read, I would have to say that it would slow parsing down. PHP is an interpretive language so it seems there would have to be file I/O to read any includes on each request.

I have also heard of something called Zend Accelerator which caches includes as one of its features. Here is what Zend says about the topic:

Quote:
Without the Zend accelerator, every time a PHP script is accessed, the script is parsed and compiled by PHP's core engine (the Zend Engine) before it is executed. As long as the script does not change, the parsing and compiling is a redundant task and creates additional load on your server's CPU. By using code caching techniques, ZPS/AE maintains the compiled bytecode version of the PHP script in memory, eliminating the need to parse and compile each time. Each time the script is requested, the precompiled version is taken from the in memory code cache. During compilation, the code is also optimized, resulting in even faster execution time.


If anyone knows of any good articles on this I would enjoy reading them.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 59 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.