doctrine dbal querybuilder as prepared statement

前端 未结 5 2007
故里飘歌
故里飘歌 2021-01-16 17:25

I\'m trying to create a Doctrine DBAL querybuilder object and setting a parameter in it. (using a postgres db, dbal 2.3.4, doctrine

$connection = $this->         


        
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-16 17:44

    The documentation states you can do the following:

    $queryBuilder
        ->select('id', 'name')
        ->from('users')
        ->where('email = ' .  $queryBuilder->createNamedParameter($userInputEmail))
    ;
    

    https://www.doctrine-project.org/projects/doctrine-dbal/en/2.9/reference/query-builder.html#binding-parameters-to-placeholders

提交回复
热议问题