The internal saved information is available as session data in your
controller.
There are points in your application where you receive data from your
view which you store inside your session plus in the db.
The data first gets to your controller and then you pass it to the
model to save it. In this way I feel it should be quite alright to
pass specific cart data to the User model by calling a specialized
function like
$this->User->mergeCart($sessionData)
from the controller.

The issue I see here is that afterwards the session should be
synchronized and that possibly the merge operation will only update
specific parts according to what is found inside the session and what
is available as a db record (not sure about the complete tasks).
Since the complexity of the mergeCart is encapsulated inside the User
model, this second issue seems quite manageable as long as the method
mergeCart is provided with all the necessary information which might
mean that you reformat the passed session data such that it is
directly saveable, as expected by the save function you will at some
point call inside mergeCart.
About synchronizing the session, you could use pass by ref or use a
return value or re-read the complete db-data into your session. In the
latter case the model would never change the controller data and the
additional call to $this->User->getCart() or similar after the call to
$this->User->mergeCart($sessionData) should be quite ok since this
will not happen too frequently.

Best,
JP




On Jan 31, 3:23 pm, kiger <[EMAIL PROTECTED]> wrote:
> Like you stated, I am saving the data to both the users table and the
> cake-defined sessions table. You pretty much hit on exactly what I am
> doing, and the majority of the code I want to extract from the users
> controller is the merge cart functionality. The reason I merge the
> cart is because I take into account that users who are not logged in
> can also maintain a cart. So when a user logs in, I merge any existing
> cart with any cart from the users table. Just a nice little feature I
> suppose.
>
> You suggested moving the code to Users::mergeCart() (which is what I
> really want to handle) but I my design concern is that merging the
> carts requires knowing what is contained in the internal saved cart
> arrays (I don't do a simple array_merge). So I just get this feeling
> in my gut that only the Carts controller should know this information,
> but at the moment I'm willing to suffer what I feel is poor design to
> save the performance overhead of using another approach. But I just
> wish there was a better way...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to