Welcome Guest, Not a member yet? Register   Sign In
SQLite Access Code does not return status
#1

Hi,
I am using version 4.1.8. I have this code in my Model:
Code:
public function createUser($data)
    {
        $qryBuilder = $this->db->table('users');
        $status = $qryBuilder->insert($data);
        // if ($this->db->affectedRows() > 0) {
        //    return true;
        // } else {
        //    return false;
        // }
        return $status;
    }

When the function succeeds, i get a "true" in the $status variable. But when the query fails, I do not get the $status returned instead the system crashes with the following error:
Code:
ErrorException

SQLite3::exec(): UNIQUE constraint failed: users.email


Is this bug or I have to do something else like try-catch??
Reply
#2

Remove uniqueness from a field or check for existing values for that field.
Reply
#3

(02-20-2022, 03:47 PM)murugappan Wrote: Is this bug or I have to do something else like try-catch??

It is not a bug.
When `DBDebug` is true, database errors will be displayed.
Reply
#4

(This post was last modified: 02-20-2022, 07:38 PM by murugappan.)

(02-20-2022, 03:59 PM)iRedds Wrote: Remove uniqueness from a field or check for existing values for that field.
Hi iRedds,

I am sorry that is not a solution. Its more like a work-around for a bug.

(02-20-2022, 04:49 PM)kenjis Wrote:
(02-20-2022, 03:47 PM)murugappan Wrote: Is this bug or I have to do something else like try-catch??

It is not a bug.
When `DBDebug` is true, database errors will be displayed.

Hi Kenjis,

Yes i fixed that and it works. I set the value in the .env file too.

Thank you so much.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB