Lets say that I have a table with column called a
. It has index UNIQUE KEY
on it.
In ORM model, I try to insert into that table. This is a way to catch Database_Exception [ 1062 ]
that occurs when user tries to insert something in column a
that's not unique:
function save(Validation $validation = null) {
try {
parent::save($validation);
}
catch (Database_Exception $exception) {
if ($exception->getCode() === 1062) {
// PK?
}
}
}
Now I'm trying to get primary key of entry that already have that content what I tried to duplicate. Is it possible without any more SQL queries? I hope that primary key of that row is returned somewhere.
Sorry about non-sense, but it was kinda hard to explain. Thanks in an advice!