T
T
Timur Yakhin2014-06-05 16:48:58
MySQL
Timur Yakhin, 2014-06-05 16:48:58

Does the Kohana ORM have a means to control the response to an add and update error?

There is an orm in the kohana framework, in the orm classes there is a save() method - save, which performs either an insert query or an update query to the database, depending on whether we create a new record or edit an existing one.
Added unique keys to the database for control. Because of this, when inserting records with non-unique fields using kohana orm, an error occurs and execution stops.
How to make it so that the execution does not stop, I see two ways that I don’t like:
1. Use direct SQL queries to the database (do not use orm)
2. Wrap each save() in a try { } catch construction You
can also before each save( ) to check for the existence of records with similar fields in the database, but this is too resource-intensive in my opinion.
The question is: Does the Kohana ORM have a means to control the response to an add and update error? Those. whether it is possible to fasten ignore in orm?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Lesnykh, 2014-06-05
@temoffey

As far as I know, it is impossible to build such a query with the help of a builder. Need to write raw-sql

DB::query(Database::INSERT, 'INSERT IGNORE INTO table VALUES (...)')->execute();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question