There's this table.
| id | domain |
id
is the primary key. domain
is a unique key.
I want to:
id
for 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?
Until someone says otherwise, I'm saying No, that's the best way.