validation Check

I am using the following code to check whether the username already exists

Here User is one model and i am accessing data from table ‘user’.

Can anyone tell me wats wrong in the code…why its not echoing the result

I checked everything fine till criteria part.

some thing wrong with accessing data.


function checkUserName($username) {


    $mod = new User;

    $criteria = new CDbCriteria;

    $criteria->condition = "UserName=:UserName";

    $criteria->params = array(":UserName"=>$username);

    

    $mod = $mod->findAll($criteria);

    echo $mod->UserName;

    die();

  }

duplicated http://www.yiiframework.com/forum/index.php?/topic/6600-validation/