CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 How to halt db in php

Print topic Send  topic

Author Message
elrial

Posts: 12
Posted: 10/24/2007, 5:47 AM

Hi,

I'm sure there is a way to do it in ASP but is there a way to stop all insert statements while retrieving the info of the last record in PHP?

I need to select the last email address inserted but what if someone adds their details while I'm selecting and I end up selecting the wrong record?

I know this is a first grade question, but I simply didn't know where else to ask, if anyone can point me in the right direction I'd be so grateful.
View profile  Send private message
wkempees


Posts: 1679
Posted: 10/24/2007, 5:54 AM

Search the forum for last_insert_ID to get the code for this in MySQL.
You do not have to stop the database, it works like this:
After SQL INSERT has done it's work, you SELECT LAST_INSERT_ID on the table in question.
It will alwasy return the correct ID, as long as you do it in the same dbconnect.
So do not open a new connection, just do the select.
If your insert is a multi row insert, the last ID is returned, which is another problem as you have to query the number of inserted rows also.
But if you stick to the above, it should work ok.
Hint: After INSERT

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.