[thelist] PHP/MySQL dates, times and autoincrements

Chris W. Parker cparker at swatgear.com
Fri Apr 26 17:38:01 CDT 2002


john,

i feel your pain.

chris.

<tip type="Resources" author="Chris Parker">
Can't find what you're looking for? Ever heard of Google Groups? try
http://groups.google.com. It's a very handy place to search for answers.
And you can be selective with where and what groups you search.
</tip

> -----Original Message-----
> From: John Corry [mailto:webshot at members.evolt.org]
> Sent: Friday, April 26, 2002 3:26 PM
> To: thelist at lists.evolt.org
> Cc: Rudy
> Subject: [thelist] PHP/MySQL dates, times and autoincrements
>
>
> I'm about 75% done with the most complex thing I've ever
> built and I need a little help to get the rest of the way there.
>
> 1) I'm working A LOT with dates and times in PHP/MySQL. PHP
> seems to rely on timestamps, but the MySQL datetime type is a
> string. Generally, it seems like I might be best off working
> with timestamps in my scripts, and converting to the MySQL
> datetime format when I store values in the db. Can anyone
> confirm that I'm thinking straight or clue me in to anything
> I might be missing?
>
> 2) In my hand rolled ordering process, a user goes through a
> series of forms, all of the values are finally displayed on a
> 'confirm your order' page (and all the values they entered
> are on the page as hidden form fields) with a submit button
> to 'confirm'. OK...now I have to write the script that
> happens when you confirm. This script will
> 1) create a customer in the customer table
> 2) create a recipient (of flowers) in the recipient table
> 3) create an order in the orders table
>
> Ok...I have to run the queries so that I insert the new
> customer and new resipient first, then get their ID numbers
> to store in the orders table. So, MySQL has a
> LAST_INSERT_ID() function. Does MySQL support using a SELECT
> statement for a value in an insert statment? (as in, 'insert
> into orders (ordCust) values (select custID from customers
> where custID = LAST_INSERT_ID())')? If not...how do I get the
> users id? I am using sessions...I guess I could store the
> session id in a column and match that way, but still I have
> to run the 2 insert queries (insert the customer and the
> recipient, then select the customer and recipient id's, then
> insert the order. That's 4 queries...is that OK? Is there a
> more streamlined way to do this?
>
> I'm in way over my head here and it is not fun :(
>
> <tip type="rhetorical">
> Bored with static web page design? Thinking of trying to
> build a dynamic, database driven site with processes and
> transactions and advanced user interaction? I reccomend
> taking your time, going slow, progressing in baby steps.
> Having a major deadline looming, and no idea of what you're
> doing...it sucks.
> </tip>
>
> John
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !
>



More information about the thelist mailing list