Avatar of BrianPap22
BrianPap22

asked on 

Persistent Connections & LAST_INSERT_ID (LAMP)

MySQL 5.0.27
PHP 5.2.0
Apache 2.0.59

I'm running a LAMP server and am thinking of testing out persistent connections to improve performance during peak load (several hundred users per minute). The issue is that there are several different pages in my website that insert a record to an auto_increment table, then next issue a simple "SELECT LAST_INSERT_ID()" query.  When using persistent connections, do I ever have to worry about one user getting the last_insert_id of another user in a race situation?  Is there certain coding I need to do in my PHP code to avoid this?

I've received conflicting answers to this question, so I would appreciate a little more than a simple Yes/No answer.

Thank you,
-Brian
PHPMySQL Server

Avatar of undefined
Last Comment
Sheeri
Avatar of Aamir Saeed
Aamir Saeed
Flag of Pakistan image

to avoid conflictions, try LAST_INSERT_ID() with user_id.
Avatar of BrianPap22
BrianPap22

ASKER

I don't understand what user_id is.
ASKER CERTIFIED SOLUTION
Avatar of Sheeri
Sheeri

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo