-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Labels
Description
I am running the query 'SELECT count(email) from ada'
thru this code:
$queryString = 'SELECT count(email) from ada';
$platform = Platform::get(Platform::MYSQL, '8.0'); // version defaults to x.x.99 when no patch number is given
$session = new Session($platform);
$parser = new Parser($session);
// returns a Generator. will not parse anything if you don't iterate over it
$commands = $parser->parse($queryString);
foreach ($commands as [$command, $tokenList, $start, $end]) {
// Parser does not throw exceptions. this allows to parse partially invalid code and not fail on first error
if ($command instanceof SelectCommand) {
$columns = $command->getColumns();
foreach($columns as $i => $column) {
$expression = $column->getExpression();
if ($expression instanceof FunctionCall && $expression->getFunction()->getName() == BuiltInFunction::COUNT ) {
// $expression->
}
}
}
}
which when hold with the debugger at // $expression
gives me this $command
:
from the command I have at hand, I can easily find the SimpleName
of the table involved, and also the name of the arg passed to count
. what I am missing is way to retrieve the raw count(email)
expression, so I can combine the parser results with results of other tooling involved.