PHP Doku:: Removes one of the sort fields - solrquery.removesortfield.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSuchmaschinenerweiterungenApache SolrThe SolrQuery classSolrQuery::removeSortField

Ein Service von Reinhard Neidl - Webprogrammierung.

The SolrQuery class

<<SolrQuery::removeMltQueryField

SolrQuery::removeStatsFacet>>

SolrQuery::removeSortField

(PECL solr >= 0.9.2)

SolrQuery::removeSortFieldRemoves one of the sort fields

Beschreibung

publicSolrQuery SolrQuery::removeSortField ( string $field )

Removes one of the sort fields

Parameter-Liste

field

The name of the field

Rückgabewerte

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


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
hasbridge at gmail dot com
23.07.2010 23:16
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);
?>



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)