PHPSQLParser\PHPSQLParser::getCustomFunctions PHP Method

getCustomFunctions() public method

Returns the list of custom functions
public getCustomFunctions ( ) : array
return array Returns an array of all custom functions
    public function getCustomFunctions()
    {
        return PHPSQLParserConstants::getInstance()->getCustomFunctions();
    }

Usage Example

 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');
 }