* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @link http://www.solarium-project.org/ * * @package Solarium * @subpackage Query */ /** * Update query delete command * * For details about the Solr options see: * @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22delete.22_by_ID_and_by_Query * * @package Solarium * @subpackage Query */ class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command { /** * Ids to delete * * @var array */ protected $_ids = array(); /** * Delete queries * * @var array */ protected $_queries = array(); /** * Get command type * * @return string */ public function getType() { return Solarium_Query_Update::COMMAND_DELETE; } /** * Build ids/queries based on options * * @return void */ protected function _init() { $id = $this->getOption('id'); if (null !== $id) { if (is_array($id)) { $this->addIds($id); } else { $this->addId($id); } } $queries = $this->getOption('query'); if (null !== $queries) { if (is_array($queries)) { $this->addQueries($queries); } else { $this->addQuery($queries); } } } /** * Add a single ID to the delete command * * @param int|string $id * @return Solarium_Query_Update_Command_Delete Provides fluent interface */ public function addId($id) { $this->_ids[] = $id; return $this; } /** * Add multiple IDs to the delete command * * @param array $ids * @return Solarium_Query_Update_Command_Delete Provides fluent interface */ public function addIds($ids) { $this->_ids = array_merge($this->_ids, $ids); return $this; } /** * Add a single query to the delete command * * @param string $query * @return Solarium_Query_Update_Command_Delete Provides fluent interface */ public function addQuery($query) { $this->_queries[] = $query; return $this; } /** * Add multiple queries to the delete command * * @param array $queries * @return Solarium_Query_Update_Command_Delete Provides fluent interface */ public function addQueries($queries) { $this->_queries = array_merge($this->_queries, $queries); return $this; } /** * Get all queries of this delete command * * @return array */ public function getQueries() { return $this->_queries; } /** * Get all qids of this delete command * * @return array */ public function getIds() { return $this->_ids; } }