Welcome Guest, Not a member yet? Register   Sign In
Catch database exception
#2

You can try it using CodeIgniters Exceptions.

PHP Code:
try
{
    $orderStatus = new OrderStatus;

    $orderStatus->insert(new OrderStatusEntity([
        'order_id'  => $orderId,
        'status_id' => $statusId
    
]));
}
catch (\
Exception $e)
{
    if ($e->getCode() === 1062)
    {
        log_message('warning''Duplicate status ({status}) for order {id}', [
            'status' => $statusId,
            'id'     => $orderId
        
]);
    }

    exit($e->getMessage());

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Catch database exception - by Michal_PB1 - 10-13-2020, 11:44 AM
RE: Catch database exception - by InsiteFX - 10-13-2020, 02:46 PM
RE: Catch database exception - by Michal_PB1 - 10-14-2020, 07:25 AM
RE: Catch database exception - by InsiteFX - 10-14-2020, 11:33 PM
RE: Catch database exception - by Michal_PB1 - 11-30-2020, 01:13 PM
RE: Catch database exception - by InsiteFX - 11-30-2020, 03:07 PM
RE: Catch database exception - by Michal_PB1 - 11-30-2020, 03:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB