0

I'm trying to set a variable for a user input text field that needs to check the database that it's unique.

I have used Codeigniter before and in the you set validation for this like:

$this->form_validation->set_rules('name','Name required etc','required|is_unique');

So my question is how does achieve this in redBean, i have never used it before and still learning it.

Help /advice greatly appreciated.

the_unforgiven_II
  • 361
  • 3
  • 10
  • 28

1 Answers1

0

RedBean is no application development Framework like CodeIgniter, but a DB framework. You could compare it to CI's ActiveRecord implementation although working in a different way.

So form validation isn't exactly the job of RB. You still have to use your framework of choice to implement the form validation handles. RB on the other hand can provide you the answer from the DB whether the name is unique or not using a simple query against the DB

Ex.:

$bean = R::findOne('YOURBEANTYPE', 'name = ?', array($nameValueToCheckFor));
if($bean != null) {
  echo "this is a duplicate";
}
zewa666
  • 2,593
  • 17
  • 20