PHP-Light-SQL-Parser icon indicating copy to clipboard operation
PHP-Light-SQL-Parser copied to clipboard

Table aliases show up as different tables

Open yourpropertyexpert opened this issue 10 months ago • 0 comments

I'm using this to track which of our classes reference which tables. (We use much more complex SQL than an ORM would need.)

One small point is that a table that is brought into a particular query with an alias reports as ":TABLENAME: :ALIAS:".

So, we ended up writing (inside a little foreach loop) to dedupe the returned list of tables:

if (str_contains($thistable, " ")) {
    $thistable = explode(" ", $thistable)[0];
}

It would be nice if the getAllTables() method could do this, either by default or if passed an (optional) OPTIONS parameter with some appropriate value.

... or introduce a new getAllTablesWithoutAliases() method.

If you'd be happy with the third option, I'd be happy to try a PR for you...

yourpropertyexpert avatar Mar 25 '25 13:03 yourpropertyexpert