Welcome Guest, Not a member yet? Register   Sign In
how to do unique validation, CodeIgniter2 + Doctrine2
#1

[eluser]xjermx[/eluser]
I am working with CodeIgniter2.1.0/Doctrine2.1.1

I have a registration form, and I want to check to be sure that any email address entered is unique.

I have tried this:
Code:
$this->form_validation->set_rules('email', 'E-mail',
                 'required|valid_email|is_unique[users.email]');

Which returns:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Signup_form::$db

Filename: libraries/Form_validation.php

Line Number: 954


Fatal error: Call to a member function limit() on a non-object in /../systemFolder/libraries/Form_validation.php on line 954

I have also tried following the example on the form_validation page in the user guide for CI:

Code:
$this->form_validation->set_rules('email', 'E-mail', 'callback_email_check');
(along with an email_check function, basically copy/pasted from the example in the user guide)

This gives me:

Quote:Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[email protected]' for key 'email_index'' in /../applicationFolder/libraries/Doctrine/DBAL/Statement.php:131 Stack trace: #0 /../applicationFolder/libraries/Doctrine/DBAL/Statement.php(131): PDOStatement->execute(NULL) #1 /../applicationFolder/libraries/Doctrine/ORM/Persisters/BasicEntityPersister.php(239): Doctrine\DBAL\Statement->execute() #2 /../applicationFolder/libraries/Doctrine/ORM/UnitOfWork.php(896): Doctrine\ORM\Persisters\BasicEntityPersister->executeInserts() #3 /../applicationFolder/libraries/Doctrine/ORM/UnitOfWork.php(304): Doctrine\ORM\UnitOfWork->executeInserts(Object(Doctrine\ORM\Mapping\ClassMetadata in /../applicationFolder/libraries/Doctrine/DBAL/Statement.php on line 131

What am I doing wrong? Are either of these 'correct'? Is there just something I'm missing to make one or both work? Is there a better way to go about this?


Messages In This Thread
how to do unique validation, CodeIgniter2 + Doctrine2 - by El Forum - 04-06-2012, 09:25 AM
how to do unique validation, CodeIgniter2 + Doctrine2 - by El Forum - 04-06-2012, 12:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB