If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Wich the best way to control the logic of a web application?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-19-09, 12:56
lopes_andre lopes_andre is offline
Registered User
 
Join Date: Oct 2008
Posts: 4
Wich the best way to control the logic of a web application?

Hi,

Now I'am with some doubts on how to control the logic of a web application?

So... the web application uses PHP, object oriented and PostgresSQL Database. I have developed some procedures and functions in the database but I don't know if it is correct to mix logic in the database and PHP.

What do you think aboout this? Should I mix logic in Database and PHP or should I control the logic only in the PHP?

Best Regards,
André.
Wich the best way to control the logic of a web application?
Reply With Quote
  #2 (permalink)  
Old 09-02-09, 06:21
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 362
Sorry for the late replay,I logg in today.
Functions that run at the database run quicker than with php (running 'inside' the database), but when you change the database you have to write again the functions.
I thing 'business' logic must be all together at php and to use more database specific functions at database (to insert a value at insertion etc).
You may read about mvc (example)

Last edited by dimis2500; 09-02-09 at 06:40.
Reply With Quote
  #3 (permalink)  
Old 09-02-09, 09:12
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
I go completely the other way and try and put as much business logic in the database procs as possible. Reasons are:
  • it's easy to encapsulate the logic into a single proc and then call that proc from lots of different places
  • it's easier to test the logic from the command line
  • the code is less complex - thinks lot's of separate pieces of SQL being called from within your PHP logic and the results all being tested etc etc as opposed to just calling a single proc.
  • it will be way faster
I'd just look at your database and decide what all the "actions" are that need to be performed on your data and then make those actions your procs. That's not to say no logic at all should go in your PHP but if the logic concerns the data in your database then the logic should be in your database to.
Reply With Quote
  #4 (permalink)  
Old 09-05-09, 09:41
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 362
This is a good idea when your logic is database related.
But what about not database related logic as connecting with web services,services from external sites or a session shopping card?.
You will have 2 buisness logic layers ?
The plus you write, you may have them when you will use a framework as Yii or your framework with simiral logic.
For example you write a model function returning the data you want[edit]Maybe the model functions use database procs-this is not related with your php application logic.
As I already said it is quicker the database related procedures to run inside databases ,another is that we can use them from separate programs (web app and desktop application for example).

Last edited by dimis2500; 09-06-09 at 06:16.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On