Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Request #17286 Change of bindValue/Array and bindParam/Array
Submitted: 2010-04-01 22:25 UTC
From: edlman Assigned:
Status: Open Package: MDB2 (version 2.5.0b2)
PHP Version: 5.3.2 OS: All
Roadmaps: (Not assigned)    
Subscription  


 [2010-04-01 22:25 UTC] edlman (Martin Edlman)
Description: ------------ Binding array of values in bindValueArray() throwed error (originated in bindValue()) when there was an element in the value array which was not found in the this->positions array. This is fixed in 2.5.0 by checking errorCode after return from bindValue. I offer even more elegant ways to solve this. One way is to walk the values array itself and lookup its key in the this->positions array to find a position for the types array. If the key is not found in the this->positions then it's not going to database. Other (even shorter) way is to walk the this->positions array so we know the position for the types array and the parameter name for the values array. This way we don't need to test result of the bindValue() as this must always succeed. So we can remove tests from bindValue() and we can remove test for returned value from bindValue() in bindValueArray() which will speed it up (a little bit). Please see attached patch (for version 2.5.0b2)

Comments

 [2010-04-01 22:29 UTC] edlman (Martin Edlman)
 [2010-04-01 23:46 UTC] edlman (Martin Edlman)
-Summary: Change od bindValueArray +Summary: Change of bindValue/Array and bindParam/Array
I have modified the patch. I've split bindValue() and bindParam() to public functions which perform checks and return an error on failure. Otherwise private functions which bind values are called (_bindValue() and _bindParam()). I've modified bindValueArray() and bindParamArray() to call private _bind* functions and simplified them as much as possible. The types array (when not passed) is initialized with the size of this->positions.
 [2010-04-01 23:48 UTC] edlman (Martin Edlman)
 [2012-10-24 20:30 UTC] danielc (Daniel Convissor)
-Type: Bug +Type: Feature/Change Request