public function actionValidName() { $record = Infrastructure::model()->findByAttributes(array('Name' => $_REQUEST['infraname'])); $count = count($record); if ($count === 0) { $output = true; } else { $output = false; } echo json_encode($output); }