我有一个名为 的数据库表Student,列为id, name, age。 
id是主键,name不为空,age可以为空
我想在 php Zend 中实现以下内容:
如果值不同,则仅在 db 中添加重复的学生。nameage
在 function/action 内部addStudentAction,我正在调用 Student 模型的函数 -findStudent以实现要求:
public function findStudent($name)
{
    $result = null;
    $select = $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
    ->setIntegrityCheck(false)
    ->where('student.name = ?', $name);
    //error_log($select->assemble());
    $result = $this->getAdapter()->fetchRow($select);
    return $result;
}
public function addStudentAction() {
    $data = $_POST;
    $studentModel = new Application_Model_Student;
    $result = $studentModel->findStudent($data['name']);
    if(!empty($result)) { 
        error_log("found student name in db, going to get age");
       //Check for age
       if( (!empty($result['age'] )) {
             if( $result['age'] != $data['age']) {
                  error_log("going to add student as new record");
                  return $this->insert($data);
             }
             else {
                  error_log("not adding new student record ");
             }
       }
    }
}
现在,可能有多个学生记录具有相同name但不同的age值。因此,在添加新学生时,我需要将所有记录的年龄(如果名称匹配)与传入的年龄值进行比较。
实现此要求的最佳方法是什么?任何帮助是极大的赞赏。
谢谢