code: static protected function doctrineQuery($tableName, $field, $generate)
      {
          return \Doctrine_Query::create()
                                ->select($field)
                                ->from($tableName)->where("$field = ?", $generate)
                                ->execute(array(), \Doctrine_Core::HYDRATE_SINGLE_SCALAR);
      }
docs: Doctgrine ORM v1.2 generate query
  
  @param string $tableName
  @param string $field
  @param string $generate
  @return int