Re: Creating single row for multiple items.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 12:38 AM +0100 9/10/08, Ashley Sheridan wrote:
I'm assuming because this is part of a shopping cart, so he would have
to put the data into the database only to retrieve it again, which is a
little bit of a waste.


If it's a shopping cart filled with Pianos, it's going to be heavy anyway. :-)

From my perspective, there's nothing wrong with (and a lot right with) storing an order number in a database (orders table) with all the item numbers that are associated/ordered with that order. He does not have to repeat all the data associated with each item purchased (i.e., name, price, shipping, etc.). It's just the order number with the purchased item numbers.

At some point, he has to pull the order together, show the user what they are buying, take payment for the items, and fulfill the order. You certainly don't need a collection of arrays containing all the bits and pieces of the order for you to figure out where everything is and assemble the transaction. The process is *much* simpler to process as an order in a database -- my opinion.

Cheers,

tedd


As for how to do it, I'd look through the arrays you have and use
associative arrays (where the order number is the key of the array
element) and set the price if the array element is just being set (use
the isset() function for this) and increment it if it already exists.


Ash
www.ashleysheridan.co.uk

Return-path:
	<php-general-return-279758-ash=ashleysheridan.co.uk@xxxxxxxxxxxxx>
Envelope-to: ash@xxxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 10 Sep 2008 00:31:46 +0100
Received: from [216.92.131.4] (port=25033 helo=lists.php.net) by
	zencphosting11.zen.co.uk with esmtp (Exim 4.68) (envelope-from
	<php-general-return-279758-ash=ashleysheridan.co.uk@xxxxxxxxxxxxx>) id
1KdCgU-0003IU-E0 for ash@xxxxxxxxxxxxxxxxxxxx; Wed, 10 Sep 2008 00:31:46
	+0100
X-Host-Fingerprint: 216.92.131.4 lists.php.net Received: from [216.92.131.4] ([216.92.131.4:24918] helo=lists.php.net) by
	pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id
	60/B9-23799-16707C84 for <ash@xxxxxxxxxxxxxxxxxxxx>; Tue, 09 Sep 2008
	19:31:45 -0400
Received: (qmail 95720 invoked by uid 1010); 9 Sep 2008 23:31:32 -0000
Mailing-List: contact php-general-help@xxxxxxxxxxxxx; run by ezmlm
Precedence: bulk
list-help: <mailto:php-general-help@xxxxxxxxxxxxx>
list-unsubscribe: <mailto:php-general-unsubscribe@xxxxxxxxxxxxx>
list-post: <mailto:php-general@xxxxxxxxxxxxx>
Delivered-To: mailing list php-general@xxxxxxxxxxxxx
Received: (qmail 95713 invoked from network); 9 Sep 2008 23:31:31 -0000
Authentication-Results: pb1.pair.com smtp.mail=tedd.sperling@xxxxxxxxx;
	spf=unknown; sender-id=unknown
Authentication-Results: pb1.pair.com header.from=tedd.sperling@xxxxxxxxx;
	sender-id=unknown
Received-SPF: unknown (pb1.pair.com: domain gmail.com does not designate
	76.96.30.48 as permitted sender)
X-PHP-List-Original-Sender: tedd.sperling@xxxxxxxxx
X-Host-Fingerprint: 76.96.30.48 qmta05.emeryville.ca.mail.comcast.net X-Authority-Analysis: v=1.0 c=1 a=ScsBlOKGSAsA:10 a=jFRa_u9Lu-YA:10 a=yZEG99RIAAAA:8 a=oKA0wkP2AAAA:8 a=PFFhWekOAAAA:8 a=0jRUIoGgooorb-81zc4A:9 a=D833IUriJyPirLy-2bwA:7 a=C1lfn_RRjP3z5y6xorFLrp8CtiYA:4 a=h9s5Ru71U4oA:10
Mime-Version: 1.0
Message-Id: <p06240804c4ecb5f93629@[192.168.1.101]>
In-Reply-To: <000901c90be7$c52cfaa0$4f86efe0$@coder@tx.rr.com>
References: <000901c90be7$c52cfaa0$4f86efe0$@coder@tx.rr.com>
Date: Tue, 9 Sep 2008 19:31:23 -0400
To: <php-general@xxxxxxxxxxxxx>
From: tedd <tedd.sperling@xxxxxxxxx>
Content-Type: text/plain; charset="us-ascii" ; format="flowed"
Subject: Re:  Creating single row for multiple items.
Content-Transfer-Encoding: 7bit

At 10:04 PM -0600 8/31/08, Tom Shaw wrote:
My array looks very similar to this. I need to create a single row for the
items that have the same order number for CSV export.  I'd prefer to do this
PHP wise instead of SQL. But would appreciate any help I can get.

$ar = array(

   array(

     "order_id" => "34",

     "order_number" => "35Y345Y356YU3",

     "order_name" => "Steinway Grand Piano #11",

     "order_ordered_size" => "Grand",

     "order_sales_price" => "78671.90",

     "order_shipping_price" => "7.85",

     "order_shipping_extra" => "0.06",

   ),


My first question is:

$78 THOUSAND DOLLARS FOR A FRAKING PIANO ???!!!???

Now that I've composed myself.

What's wrong with use MySQL and letting it do the hard stuff?

After all, what you are attempting to do is what MySQL works best at -- namely pull all all the records that have the same order number. Why make it harder on yourself?

Cheers,

tedd




--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux