Remove a custom function from the parser. no return value
public removeCustomFunction ( String $token ) : null | ||
$token | String | The name of the function to remove |
return | null |
public function testCustomfunction() { try { $sql = "SELECT PERCENTILE(xyz, 90) as percentile from some_table"; $parser = new PHPSQLParser(); $parser->addCustomFunction("percentile"); $p = $parser->parse($sql, true); } catch (\Exception $e) { $p = array(); } $this->assertSame(ExpressionType::CUSTOM_FUNCTION, $p['SELECT'][0]['expr_type'], 'custom function within SELECT clause'); $parser = new PHPSQLParser(); $parser->addCustomFunction("percentile"); $parser->addCustomFunction("foo_bar"); $p = $parser->getCustomFunctions(); $this->assertEquals(array("PERCENTILE", "FOO_BAR"), $p, 'custom function list'); $parser = new PHPSQLParser(); $parser->addCustomFunction("percentile"); $parser->addCustomFunction("foo_bar"); $parser->removeCustomFunction('percentile'); $p = $parser->getCustomFunctions(); $this->assertEquals(array("FOO_BAR"), $p, 'remove custom function from list'); }