Skip to content

Commit a7dc993

Browse files
committed
Merge pull request #83 from Dewstar/master
Added optimizeIndex to Helper class
2 parents b67b72d + 09b1e4f commit a7dc993

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,4 @@ $result = SphinxQL::create($this->conn)
394394
* `Helper::create($conn)->dropFunction($udf_name)`
395395
* `Helper::create($conn)->attachIndex($disk_index, $rt_index)`
396396
* `Helper::create($conn)->flushRtIndex($index)`
397+
* `Helper::create($conn)->optimizeIndex($index)`

src/Helper.php

+12
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,16 @@ public function flushRtIndex($index)
275275
{
276276
return $this->query('FLUSH RTINDEX '.$this->getConnection()->quoteIdentifier($index));
277277
}
278+
279+
/**
280+
* OPTIMIZE INDEX syntax
281+
*
282+
* @param string $index
283+
*
284+
* @return SphinxQL A SphinxQL object ready to be ->execute();
285+
*/
286+
public function optimizeIndex($index)
287+
{
288+
return $this->query('OPTIMIZE INDEX '.$this->getConnection()->quoteIdentifier($index));
289+
}
278290
}

tests/SphinxQL/HelperTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,8 @@ public function testMiscellaneous()
183183

184184
$query = Helper::create($this->conn)->flushRtIndex('rt');
185185
$this->assertEquals('FLUSH RTINDEX rt', $query->compile()->getCompiled());
186+
187+
$query = Helper::create($this->conn)->optimizeIndex('rt');
188+
$this->assertEquals('OPTIMIZE INDEX rt', $query->compile()->getCompiled());
186189
}
187190
}

0 commit comments

Comments
 (0)