Skip to content

Rewrite statements with WHERE clause #12

Answered by mapcentia
mapcentia asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the input. I figured out how to create a walker class, which will (I think) set WHERE clause on all statements. Thanks for the great work!

class TableWalker extends BlankWalker
{
    public function walkSelectStatement(Select $statement)
    {
        foreach ($statement->from->getIterator() as $from) {
            // Check rule for $from->name->relation->value and set WHERE
            $statement->where->and("userid='SELECT'");
        }
        parent::walkSelectStatement($statement);
    }

    public function walkUpdateStatement(Update $statement)
    {
        // Check rule for $statement->relation->relation->relation->value and set WHERE
        $statement->where->and("us…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mapcentia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #11 on May 13, 2022 10:44.