RE: 2 Questions.

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

 



-----Original Message-----
From: Tom Shaw [mailto:php.coder@xxxxxxxxx] 
Sent: Saturday, September 13, 2008 9:52 PM
To: 'Jochem Maas'
Subject: RE:  2 Questions.

iamjochem wrote:

>> My second question is I've designed a very simple Postgres database
> wrapper.
>> The methods are exactly what you would assume to see in any db wrapper a
>> pg_query, pg_fetch_array. My question is in the db wrapper, is there an
> easy
>> way to always include the table name as an index in all my pg_fetch_array
>> returned results? The reason I ask is when designing my tables I'm
> delegated
>> to prefixing my column names i.e. users_name instead of just name or
>> forum_posts instead of just posts to make sure there's no collision.  
>>
> 
> have your simple wrapper do something like:
> 
> $sql = "SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1";
> 
> with regard to generating the query. if your wrapper doesn't generate the
> SQL then you'll have to parse the given SQL and rewrite it ... good luck
> with that.

I'm not sure if my wrapper is a good place for the sql but I bet it's worth
investigating further. I like the web site iamjokem. Im not sure if that's a
jokem too but I couldn't figure it out... 

-----Original Message-----
From: Jochem Maas [mailto:jochem@xxxxxxxxxxxxx] 
Sent: Saturday, September 13, 2008 8:35 PM
To: Tom Shaw
Cc: 'PHP General'
Subject: Re:  2 Questions.

Tom Shaw schreef:
> I should have mentioned that I use a *normalized* database wharehousing
> pattern where each row represents a distinct item being purchased. There
> could be fifty rows corresponding to a single order transaction like what
> you would see in something like an itunes music purchase. So using the
auto
> increment id would not work to differentiate between orders. Another user
> mentioned microtime.

whoa, race car hey? let's have a race.

normalized smormalized. every order related system I've looked at, built or
worked with made a clear distinction between an **order** and an
**orderline**,
all you seem to have is an order line ... who do they belong to? are you
replicating the customer details and shipping address in each row? (if so
I hardly call that normalized)

use generators or sequences or 'auto increment ids' or whatever your DB
calls
it, dump the timestamp/microtime nonsense, and rework you DB schema to
incorporate order **and** orderline entities ... and use a required foreign
key
in each orderline to reference the relevant order.

with regard to iTunes store, steve jobs can go shove it ... but I'll wadger
my soul that the guys that built it know the difference between an order
and an order line and that they use both concepts.

> -----Original Message-----
> From: Jochem Maas [mailto:jochem@xxxxxxxxxxxxx] 
> Sent: Saturday, September 13, 2008 6:06 PM
> To: Tom Shaw
> Cc: 'PHP General'
> Subject: Re:  2 Questions.
> 
> Tom Shaw schreef:
>> Can anybody give me any good reasons not to use a time stamp as an order
>> number in my shopping cart. It seems to me that the number is guaranteed
> to
>> be random and it saves having to make an extra time column to keep track
> of
>> the order. The only small concern I have is the chance that somebody
> orders
>> at the exact same time as somebody else but the chance of that has got to
> be
>> incredibly small but possible. 
>>
> 
> 1. order number are often *required* (for accounting purposes) to be
> consecutive
> 2. the chance is small, yet it is there ... agravated by the fact that
most
> orders
> are placed during a concentrated period of the day.
> 
> I have no idea what you mean by 'extra time column' and/or using it to
keep
> track of an order... but most DBMSs have the ability to auto store a
> timestamp
> into a field when the given record is created.
> 
> oh ... timestamps are hardly random.
> 
>>  
>>
>> My second question is I've designed a very simple Postgres database
> wrapper.
>> The methods are exactly what you would assume to see in any db wrapper a
>> pg_query, pg_fetch_array. My question is in the db wrapper, is there an
> easy
>> way to always include the table name as an index in all my pg_fetch_array
>> returned results? The reason I ask is when designing my tables I'm
> delegated
>> to prefixing my column names i.e. users_name instead of just name or
>> forum_posts instead of just posts to make sure there's no collision.  
>>
> 
> have your simple wrapper do something like:
> 
> $sql = "SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1";
> 
> with regard to generating the query. if your wrapper doesn't generate the
> SQL then you'll have to parse the given SQL and rewrite it ... good luck
> with that.
> 
> 
>> Cheers
>>
>>  
>>
>> Thomas Shaw
>>
>> Php.coder@xxxxxxxxx
>>
>>  
>>
>>
> 
> 


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


-- 
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