FOFModel::buildQuery

Builds the SELECT query