I'm learning MVC with Symfony2 by attempting to build a simple shopping cart. I'm using the FOSUserBundle and have an Admin view and a normal (or user) view. I'm a newbie with Symfony and PHP.
Setup: I have an associative session array (cartArray) which contains the id, the name, and the price of the products selected by a 'normal' user...
array(3) { [5]=> array(3) { [0]=> string(7) "Rooster" [1]=> int(1) [2]=> float(105) }
[6]=> array(3) { [0]=> string(11) "Apple Sauce" [1]=> int(1) [2]=> float(9.25) }
[1]=> array(3) { [0]=> string(5) "Water" [1]=> int(5) [2]=> float(2.75) }
}
... I want that information to be posted into my database so I can retrieve it for my Admin view (created from FOSUserBundle) so that on that page there would be 2 tables.
- Table 1: All session arrays being used. (From the start of session array until the user selects to buy those products)
- Table 2: All products bought (after the user selects buy)
Details: 'Normal' user is brought to a screen after they sign in which shows products. Once they click 'Add Product to Cart', the product gets added to cartArray. Once they click 'Proceed to Checkout', they can select 'Buy' and then the session array is emptied: $request->getSession()->invalidate(1);
In the research I've done like this and or this (those two examples are not all) fail to give answers using Symfony or non associative arrays.
Any help would really be appreciated and if more information is needed, I'll be happy to provide it. Thanks!