public function getUserIdsFromName($name, $count, $suggestion_format = SOCIAL_PROFILE_SUGGESTIONS_ALL) {
    $query = $this->startQuery();
    $name = '%' . ltrim($query->escapeLike($name)) . '%';

    switch ($suggestion_format) {
      case SOCIAL_PROFILE_SUGGESTIONS_USERNAME:
        $query->condition('uf.name', $name, 'LIKE');
        break;

      case SOCIAL_PROFILE_SUGGESTIONS_FULL_NAME:
      case SOCIAL_PROFILE_SUGGESTIONS_ALL:
        if ($this->useFullName()) {
          $strings = explode(' ', $name);

          if (count($strings) > 1) {
            $query->where("CONCAT(TRIM(fn.field_profile_first_name_value), ' ', TRIM(ln.field_profile_last_name_value)) LIKE :full_name", [
              ':full_name' => $name,
            ]);

            $query = $this->sortQuery($query, $name, $suggestion_format);
            $results = $this->endQuery($query, $count);

            if (count($results) > 0) {
              return $results;
            }

            // Fallback to creating a new query if there is no hit on full name.
            $query = $this->startQuery();
          }
        }

        $or_query = $query->orConditionGroup();

        if ($this->useFullName()) {
          $or_query
            ->condition('fn.field_profile_first_name_value', $name, 'LIKE')
            ->condition('ln.field_profile_last_name_value', $name, 'LIKE');
        }

        // Add name only when needed.
        if ($suggestion_format === SOCIAL_PROFILE_SUGGESTIONS_ALL) {
          $or_query->condition('uf.name', $name, 'LIKE');
        }

        if ($this->addNickName() === TRUE) {
          $or_query->condition('nn.field_profile_nick_name_value', $name, 'LIKE');
        }

        $query->condition($or_query);

        break;
    }

    // Now we sort the query.
    $query = $this->sortQuery($query, $name, $suggestion_format);

    return $this->endQuery($query, $count);
  }
public function getUserIdsFromName($name, $count, $suggestion_format = SOCIAL_PROFILE_SUGGESTIONS_ALL) {
    $query = $this->startQuery();
    $name = '%' . ltrim($query->escapeLike($name)) . '%';

    switch ($suggestion_format) {
      case SOCIAL_PROFILE_SUGGESTIONS_USERNAME:
        $query->condition('uf.name', $name, 'LIKE');
        break;

      case SOCIAL_PROFILE_SUGGESTIONS_FULL_NAME:
      case SOCIAL_PROFILE_SUGGESTIONS_ALL:
        if ($this->useFullName()) {
          $strings = explode(' ', $name);

          if (count($strings) > 1) {
            $query->where("CONCAT(TRIM(fn.field_profile_first_name_value), ' ', TRIM(ln.field_profile_last_name_value)) LIKE :full_name", [
              ':full_name' => $name,
            ]);

            $query = $this->sortQuery($query, $name, $suggestion_format);
            $results = $this->endQuery($query, $count);

            if (count($results) > 0) {
              return $results;
            }

            // Fallback to creating a new query if there is no hit on full name.
            $query = $this->startQuery();
          }
        }

        $or_query = $query->orConditionGroup();

        if ($this->useFullName()) {
          $or_query
            ->condition('fn.field_profile_first_name_value', $name, 'LIKE')
            ->condition('ln.field_profile_last_name_value', $name, 'LIKE');
        }

        // Add name only when needed.
        if ($suggestion_format === SOCIAL_PROFILE_SUGGESTIONS_ALL) {
          $or_query->condition('uf.name', $name, 'LIKE');
        }

        if ($this->addNickName() === TRUE) {
          $or_query->condition('nn.field_profile_nick_name_value', $name, 'LIKE');
        }

        $query->condition($or_query);

        break;
    }

    // Now we sort the query.
    $query = $this->sortQuery($query, $name, $suggestion_format);

    return $this->endQuery($query, $count);
  }
public function getUserIdsFromName ( $ name , $ count , $ suggestion_format = SOCIAL_PROFILE_SUGGESTIONS_ALL ) { $ query = $ this -> startQuery ( ) ; $ name = '%' . ltrim ( $ query -> escapeLike ( $ name ) ) . '%' ; switch ( $ suggestion_format ) { case SOCIAL_PROFILE_SUGGESTIONS_USERNAME : $ query -> condition ( 'uf.name' , $ name , 'LIKE' ) ; break ; case SOCIAL_PROFILE_SUGGESTIONS_FULL_NAME : case SOCIAL_PROFILE_SUGGESTIONS_ALL : if ( $ this -> useFullName ( ) ) { $ strings = explode ( ' ' , $ name ) ; if ( count ( $ strings ) > 1 ) { $ query -> where ( "CONCAT(TRIM(fn.field_profile_first_name_value), ' ', TRIM(ln.field_profile_last_name_value)) LIKE :full_name" , [ ':full_name' => $ name , ] ) ; $ query = $ this -> sortQuery ( $ query , $ name , $ suggestion_format ) ; $ results = $ this -> endQuery ( $ query , $ count ) ; if ( count ( $ results ) > 0 ) { return $ results ; } // Fallback to creating a new query if there is no hit on full name. $ query = $ this -> startQuery ( ) ; } } $ or_query = $ query -> orConditionGroup ( ) ; if ( $ this -> useFullName ( ) ) { $ or_query -> condition ( 'fn.field_profile_first_name_value' , $ name , 'LIKE' ) -> condition ( 'ln.field_profile_last_name_value' , $ name , 'LIKE' ) ; } // Add name only when needed. if ( $ suggestion_format === SOCIAL_PROFILE_SUGGESTIONS_ALL ) { $ or_query -> condition ( 'uf.name' , $ name , 'LIKE' ) ; } if ( $ this -> addNickName ( ) === TRUE ) { $ or_query -> condition ( 'nn.field_profile_nick_name_value' , $ name , 'LIKE' ) ; } $ query -> condition ( $ or_query ) ; break ; } // Now we sort the query. $ query = $ this -> sortQuery ( $ query , $ name , $ suggestion_format ) ; return $ this -> endQuery ( $ query , $ count ) ; }
Get a list of account IDs whose account names begin with the given string.

@param string $name
The string to search for.
@param int $count
The number of results to return.
@param string $suggestion_format
(optional) The suggestion format.

@return int[]
An array of account IDs for accounts whose account names begin with the
given string.
Get a list of account IDs whose account names begin with the given string .