略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: SolrQuery::removeSortField

2024-04-30

SolrQuery::removeSortField

(PECL solr >= 0.9.2)

SolrQuery::removeSortFieldRemoves one of the sort fields

说明

public SolrQuery::removeSortField(string $field): SolrQuery

Removes one of the sort fields

参数

field

The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

add a noteadd a note

User Contributed Notes 1 note

up
0
hasbridge at gmail dot com
11 years ago
This method will generate a notice if you try and remove a sort field that isn't set. This can happen if you call getSortFields, which will return an array like:

[0] => 'fieldName asc',
[1] => 'fieldName desc

But if you try and call:

<?php
$object
->removeSortField('fieldName asc');
?>

You will get a notice. Instead, you need to truncate the sort order (' asc', ' desc') part of it. Something like:

<?php
$fieldName
= trim(str_replace(array('asc', 'desc')), '', $fieldName);
?>

官方地址:https://www.php.net/manual/en/solrquery.removesortfield.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3