protected function setupSphinxSearch($filter_name, $value, $machine_filter)
	{
		$sphinx_key_column = $this->query->quoteIdent($machine_filter['sphinx_key_column']);
		$temp_table = $this->query->quoteIdent('_sphinx_temp_'.$filter_name);
		$index_name = $this->query->quoteIdent($machine_filter['index_name']);

		$this->query->where("$sphinx_key_column IN (SELECT $temp_table.id FROM $temp_table)");

		$this->before_query[] = function() use ($temp_table, $index_name, $value, $machine_filter) {
			$this->query->pdo->query("CREATE TEMPORARY TABLE $temp_table (`id` INT(11) NOT NULL)");

			$sq = $this->sphinx->select('*')->from($index_name)->where('MATCH(?)', $value);
			if (!empty($machine_filter['sphinx_option'])) {
				$sq->option($machine_filter['sphinx_option']);
			}
			// TODO: Add param. conditions here
			$sr = $sq->query();
			$ins = $this->query->pdo->prepare("INSERT INTO $temp_table (id) VALUES (:id)");
			foreach ($sr as $row) {
				$ins->execute(array('id' => $row['id']));
			}
		};

		$this->after_query[] = function() use ($temp_table) {
			$this->query->pdo->query("DROP TEMPORARY TABLE $temp_table");
		};
	}
protected function setupSphinxSearch($filter_name, $value, $machine_filter)
	{
		$sphinx_key_column = $this->query->quoteIdent($machine_filter['sphinx_key_column']);
		$temp_table = $this->query->quoteIdent('_sphinx_temp_'.$filter_name);
		$index_name = $this->query->quoteIdent($machine_filter['index_name']);

		$this->query->where("$sphinx_key_column IN (SELECT $temp_table.id FROM $temp_table)");

		$this->before_query[] = function() use ($temp_table, $index_name, $value, $machine_filter) {
			$this->query->pdo->query("CREATE TEMPORARY TABLE $temp_table (`id` INT(11) NOT NULL)");

			$sq = $this->sphinx->select('*')->from($index_name)->where('MATCH(?)', $value);
			if (!empty($machine_filter['sphinx_option'])) {
				$sq->option($machine_filter['sphinx_option']);
			}
			// TODO: Add param. conditions here
			$sr = $sq->query();
			$ins = $this->query->pdo->prepare("INSERT INTO $temp_table (id) VALUES (:id)");
			foreach ($sr as $row) {
				$ins->execute(array('id' => $row['id']));
			}
		};

		$this->after_query[] = function() use ($temp_table) {
			$this->query->pdo->query("DROP TEMPORARY TABLE $temp_table");
		};
	}
protected function setupSphinxSearch ( $ filter_name , $ value , $ machine_filter ) { $ sphinx_key_column = $ this -> query -> quoteIdent ( $ machine_filter [ 'sphinx_key_column' ] ) ; $ temp_table = $ this -> query -> quoteIdent ( '_sphinx_temp_' . $ filter_name ) ; $ index_name = $ this -> query -> quoteIdent ( $ machine_filter [ 'index_name' ] ) ; $ this -> query -> where ( "$sphinx_key_column IN (SELECT $temp_table.id FROM $temp_table)" ) ; $ this -> before_query [ ] = function ( ) use ( $ temp_table , $ index_name , $ value , $ machine_filter ) { $ this -> query -> pdo -> query ( "CREATE TEMPORARY TABLE $temp_table (`id` INT(11) NOT NULL)" ) ; $ sq = $ this -> sphinx -> select ( '*' ) -> from ( $ index_name ) -> where ( 'MATCH(?)' , $ value ) ; if ( ! empty ( $ machine_filter [ 'sphinx_option' ] ) ) { $ sq -> option ( $ machine_filter [ 'sphinx_option' ] ) ; } // TODO: Add param. conditions here $ sr = $ sq -> query ( ) ; $ ins = $ this -> query -> pdo -> prepare ( "INSERT INTO $temp_table (id) VALUES (:id)" ) ; foreach ( $ sr as $ row ) { $ ins -> execute ( array ( 'id' => $ row [ 'id' ] ) ) ; } } ; $ this -> after_query [ ] = function ( ) use ( $ temp_table ) { $ this -> query -> pdo -> query ( "DROP TEMPORARY TABLE $temp_table" ) ; } ; }
Setup query for lookup in Sphinx search engine.

Since Sphinx is accessed using standalone MySQL connection, this
will create temporary table and populate it with the fulltext search
result. Then the temporary table will be used to access and filter
the original query.
Setup query for lookup in Sphinx search engine .