Skip to content

PDO: support bindValue based api #199

Open

Activity

  1. changed the title [-]PDO: support bindValue based api[/-] [+]PDO: support `bindValue` based api[/+] on Jan 24, 2022
  2. added
    enhancement
    on Jan 30, 2022
  3. xPaw commented on Feb 6, 2022

    @xPaw
    Contributor

    There are also bindColumn and bindParam.

  4. xPaw commented on Feb 7, 2022

    @xPaw
    Contributor

    I tried looking at this, but I can't really wrap my head around php-parser's AST.

    It seems that it would be pretty similar to findQueryStringExpression, where it finds the parent node, and then traverses the children for all the bind* calls.

  5. staabm commented on Feb 7, 2022

    @staabm
    OwnerAuthor

    It seems that it would be pretty similar to findQueryStringExpression, where it finds the parent node, and then traverses the children for all the bind* calls.

    exactly. we can only support use-cases where the bindValue (et. all) and the execute are done within the same method.

    similar to https://github.com/staabm/phpstan-dba/blob/main/src/Extensions/PdoStatementExecuteTypeSpecifyingExtension.php in which we find the corresponding sql query arg of ->prepare() which needs to be executed starting from the line where execute() is called

  6. staabm commented on Feb 7, 2022

    @staabm
    OwnerAuthor

    I tried looking at this, but I can't really wrap my head around php-parser's AST.

    for those cases I put the unit test code into https://phpast.com/ and inspect the AST which gets generated.
    it helps to find the proper traversing.

  7. xPaw commented on Feb 10, 2022

    @xPaw
    Contributor

    While there's basic support for this now, there's still things to do. In particular with bind calls being inside of if statements.

    As well as bind calls should be an error when there are also parameters being passed into execute.

    Not sure if it's worth exploring support for passing in PDO::PARAM_* as third argument in bind calls.

  8. staabm commented on Feb 10, 2022

    @staabm
    OwnerAuthor

    I agree in all mentioned points.

    We should tackle them one at a time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions