File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -270,6 +270,18 @@ public function flushRtIndex($index)
270270 return $ this ->query ('FLUSH RTINDEX ' .$ index );
271271 }
272272
273+ /**
274+ * TRUNCATE RTINDEX syntax
275+ *
276+ * @param string $index
277+ *
278+ * @return SphinxQL A SphinxQL object ready to be ->execute();
279+ */
280+ public function truncateRtIndex ($ index )
281+ {
282+ return $ this ->query ('TRUNCATE RTINDEX ' .$ index );
283+ }
284+
273285 /**
274286 * OPTIMIZE INDEX syntax
275287 *
Original file line number Diff line number Diff line change @@ -166,6 +166,38 @@ public function testCreateFunction()
166166 Helper::create ($ this ->conn )->dropFunction ('my_udf ' )->execute ();
167167 }
168168
169+ /**
170+ * @covers \Foolz\SphinxQL\Helper::truncateRtIndex
171+ */
172+ public function testTruncateRtIndex ()
173+ {
174+ SphinxQL::create ($ this ->conn )->insert ()
175+ ->into ('rt ' )
176+ ->set (array (
177+ 'id ' => 1 ,
178+ 'title ' => 'this is a title ' ,
179+ 'content ' => 'this is the content ' ,
180+ 'gid ' => 100
181+ ))
182+ ->execute ();
183+
184+ $ result = SphinxQL::create ($ this ->conn )->select ()
185+ ->from ('rt ' )
186+ ->execute ()
187+ ->getStored ();
188+
189+ $ this ->assertCount (1 , $ result );
190+
191+ Helper::create ($ this ->conn )->truncateRtIndex ('rt ' )->execute ();
192+
193+ $ result = SphinxQL::create ($ this ->conn )->select ()
194+ ->from ('rt ' )
195+ ->execute ()
196+ ->getStored ();
197+
198+ $ this ->assertCount (0 , $ result );
199+ }
200+
169201 // actually executing these queries may not be useful nor easy to test
170202 public function testMiscellaneous ()
171203 {
You can’t perform that action at this time.
0 commit comments