There are numerous ways of doing this. First of all, check that you have a constraint on your database schema that makes it impossible for two users to have the same username. Assuming that you have a class that extend Zend_Db_Table, like in your previous mail, you could create a method for it:

   /**
    * check whether a username exists
    *
    * @param string $name
    * @return bool
    */
   public function userNameExists($name) {
       $count = (int) $this->getAdapter()
       ->fetchOne("SELECT COUNT(*) FROM user WHERE username = :name",
       array('name' => $name)
       );
       //select count(*)... etc.
return ($count > 0);
       //if the user exists return true
   }

hope this helps,
MF

José de Menezes Soares Neto wrote:
Hi again friends,

I need to check if a USERNAME is already taken on table USERS.
But I don't know how to check it using ZF...

Could you help me?

best regards,

José


--
Maurice Fonk

[EMAIL PROTECTED]
http://naneau.nl/

Scio me nihil scire

Reply via email to