Sphinx\SphinxClient::setOverride PHP Method

setOverride() public method

Set attribute values override. Only one override per attribute
public setOverride ( string $attrname, integer $attrtype, array $values ) : SphinxClient
$attrname string attribute name
$attrtype integer attribute type
$values array hash that maps document IDs to attribute values
return SphinxClient
    public function setOverride($attrname, $attrtype, array $values)
    {
        if (!is_string($attrname)) {
            throw new \InvalidArgumentException('Attribute name must be a string.');
        }
        if (!in_array($attrtype, array(self::SPH_ATTR_INTEGER, self::SPH_ATTR_TIMESTAMP, self::SPH_ATTR_BOOL, self::SPH_ATTR_FLOAT, self::SPH_ATTR_BIGINT))) {
            throw new \InvalidArgumentException('Attribute type is invalid.');
        }
        $this->overrides[$attrname] = array('attr' => $attrname, 'type' => $attrtype, 'values' => $values);
        return $this;
    }

Usage Example

 public function testResetOverrides()
 {
     $sphinx = new SphinxClient();
     $sphinx->setOverride('attr', SphinxClient::SPH_ATTR_INTEGER, array(1337 => 9001));
     $sphinx->resetOverrides();
     $this->assertSame($sphinx->overrides, array());
 }
All Usage Examples Of Sphinx\SphinxClient::setOverride