Hello.

For one project I use the well-known ORM PHP-ActiveRecord .

Successfully connected, earned. But there is one big BUT. With all errors and other things, this one throws out an exception, which is not always acceptable.

For example, I need to look:

$client = \Model\Client::find($someId); 

If there is a user, but a specific model returns to me, and if not, then

 Fatal error: Uncaught exception 'ActiveRecord\RecordNotFound' 

And I need, let's say, to continue the code and do something else in the method being called. But Exception doesn't let me do that. Write try {..} catch ($ e) {..} for each reference to the model, you know, nonsense - all the beauty of ORM is lost.

setting set_exception_handler is generally a kill, after executing a callback, the execution of the script stops.

How can I continue to run the script, even if ORM threw an exception? How is it possible to get around? If it is not possible, what other ORM can you recommend (but not the Doctrine (:)?

Or am I not using it at all correctly?

PS: they would, instead of Exception, die () would call))

    2 answers 2

    Spit and put Eloquent ORM from Laravel4. It works as it should. If empty, return null. No exceptions and program interruptions. Installation example

    I do not have Slim, but a samopisny framework, but in spite of this, it is perfectly attached. Thanks to all

      In ruby ​​it is bypassed like this:

       $client = \Model\Client::find_by_id($someId); 

      or

       $client = \Model\Client::find_all_by_id($someId); 

      Try it, maybe it will work here.

      • And what, in Ruby also throws an exception to find? - Jim_Moriarty pm