Closed elieobeid7 closed 7 years ago
Hello,
You either have to change the column properties in your database (remove the fact that it can be NULL and set a default value of your choice) or you have to check beforehand (in PHP I mean) and modify the value accordingly before storing your bean.
$user = R::dispense('user');
$user->setMeta('sys.uniques', array('email')); /* can be removed afterwards */
$user->fname = 'Bob';
$user->lname = 'Sponge';
$user->email = 'bs@deepinthe.sea';
R::store($user);
?>
This way, the email field will be unique in your database. This does not mean that RedBean will check it for you when you create a new user, as it will simply raise a database exception.
You could also simply set the unique index directly in your database manager (like phpmyadmin).
Lyn.
I'm using the latest stable version, if I have to update for version 5, let me know.
lastModified
is stored as datetime. I wantgender
andverified
to have a default value of 0. I wantemail
to be unique.I tried every solution I could find on stackoverflow and nothing works