Bind variable typing

6 views
Skip to first unread message

Michael Casey

unread,
Apr 8, 2020, 8:04:35 AM4/8/20
to doctrine-user
Hi

I am starting a new Symfony5 project that uses Doctrine DBAL and an Oracle database. I am trying to figure out best practices and wanted to investigate the usage of bind variables.

I seem to have hit an issue whereby the bind variable type isn't being respected.

Here's a simple insert function:

public function createActionTypeWithBind(Request $request, Connection $conn, string $action_type_name){
    $sql = 'insert into tt_action_type (action_type_id, action_type_name) values (TT_SEQ_JUNK.nextval, :action_type_name)';
    $query = $conn->prepare($sql);
    $query->bindValue('action_type_name', $action_type_name, ParameterType::INTEGER);
    $query->execute();
 
    return new Response('done');
}

The function should fail because $action_type_name is a string and I have typed it as an integer, but the insert in fact works(!).

Can anybody enlighten me here?

Thanks,
Reply all
Reply to author
Forward
0 new messages