8

Is there a way to get a unique connection id of a PDO connection to mysql?

1
  • What do you want to do with this id? E.g.: Compare objects? Find correlating entries in mysql general query log? Implements some kind of connection pooling? ...? Commented Aug 26, 2010 at 9:08

1 Answer 1

15

Try sth like this.

print_r($dbh->query('SELECT CONNECTION_ID()')->fetch(PDO::FETCH_ASSOC)); 

you can use a regular query to execute the CONNECTION_ID() mysql command to get the connection ID.

See the mySQL manual for more

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.