New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support array binding for custom types #2357
Conversation
E.g. ->setParameter("array", $arrayOfIds, CustomType::CUSTOMTYPE)
Any update on when we could merge this? I'm having the same issue. |
@lkm I'm sorry but I don't quite get the issue. Please also provide a testcase (that also might clear things up). Otherwise we can't merge. |
Sorry @deeky666, I was going to provide a test, it somehow slipped my mind. Hopefully this casts some light on what the change is doing. I assume this would be an issue for any type (even the bundled ones), that requires a different PDO binding param type (for instance Binary) |
array( | ||
"SELECT * FROM Foo WHERE foo IN (?)", | ||
array(array('oof', 'rab')), | ||
array('customReverseType'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excuse me but I still don't get the binding type here. We only have limited types that we map to PDO types, and this one is not supported... How should we map that one to the driver? Or am I missing something here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CustomReverseType isn't a binding type, but a custom type that extends Doctrine\DBAL\Types\Type
and is added using Type::addType('customReverseType', 'Namespace\To\Types\CustomReverseType');
.
It's PDO binding type is retrieved by calling getBindingType()
this happens in Doctrine\DBAL\Connection->getBindingInfo()
.
This is especially important if you both rely on a binding type of PARAM_LOB and have implemented convertToDatabaseValue
, I'm using it like this:
...
->setParameter("id", array(binary1, binary2, binaryN), CustomBinaryType::CUSTOMBINARYTYPE);
@deeky666 Have you had time to look at this? |
Closing as stale. |
At present you are only able to have string and integer arrays as a binding parameter. If you needed any custom parsing of variables using the
Type::convertToDatabaseValue
method that needs to be executed manually on the array before, this also meant that the binding type could not be overridden, in my case of implementing binary guid\PDO::PARAM_LOB;
needed to be set before sqlite would accept it.This PR should hopefully take care of that by testing whether the incoming param is an array and then extract it into separate params.