PHP OOP, Ajax and MySQL
Posted: Fri Dec 01, 2006 7:58 am
I'm trying to get my head around OOP and Ajax at the same time (there's nothing like making life hard for yourself)
Lets take a simple example: - A sales order
The order can be considered an object with properties (order number, customer number etc...) and methods (getOrderID, setOrderID etc..)
An order will also have lines and each line will have certain characteristics (product number, price, qty etc...)
The lines can be regarded as an array of the Order object but could also be considered as objects themselves. Which way should this be done, or can it be done as both at the same time.
If I am building a rich internet application using Ajax and MySQL where the operator can dynamically add and remove lines and changes need to e sent bback to the server for validation against business rules using PHP processes, where do I store my objects (javascript client side or php server side).
Each url request for validation needs to know the whole of the order (headers and lines) and modify the line values (e.g. multi-buy discount). How do you send that information becuase I can't pass it as an object.
When I have finished with my object how do I save it out to the database, or should i be saving changes in properties as I go along.
What happens if the browser crashes or the user hits refresh. I have plans for recovering the point in the application but can't work out a way to recover the object to the browser session.
I am hopefully looking for a cookie and preferably a session free solution.
Thanks in advance
Aaron
Lets take a simple example: - A sales order
The order can be considered an object with properties (order number, customer number etc...) and methods (getOrderID, setOrderID etc..)
An order will also have lines and each line will have certain characteristics (product number, price, qty etc...)
The lines can be regarded as an array of the Order object but could also be considered as objects themselves. Which way should this be done, or can it be done as both at the same time.
If I am building a rich internet application using Ajax and MySQL where the operator can dynamically add and remove lines and changes need to e sent bback to the server for validation against business rules using PHP processes, where do I store my objects (javascript client side or php server side).
Each url request for validation needs to know the whole of the order (headers and lines) and modify the line values (e.g. multi-buy discount). How do you send that information becuase I can't pass it as an object.
When I have finished with my object how do I save it out to the database, or should i be saving changes in properties as I go along.
What happens if the browser crashes or the user hits refresh. I have plans for recovering the point in the application but can't work out a way to recover the object to the browser session.
I am hopefully looking for a cookie and preferably a session free solution.
Thanks in advance
Aaron