There's this table.
| id | domain |
id is the primary key. domain is a unique key.
I want to:
- Insert a new domain, if it doesn't exist already.
- Get the idfor that domain.
Now I'm doing it like this:
INSERT INTO domains
SET domain = 'exemple.com'
ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID(id)
Then PDO::lastInsertId() to get the id.
But it's critical that this is as fast as it could, so I though I'd ask: Can I do this in a better way?
 
    