Bug->Req #17286 [Opn]: Change of bindValue/Array and bindParam/Array

From: Date: Wed, 24 Oct 2012 15:30:43 +0000
Subject: Bug->Req #17286 [Opn]: Change of bindValue/Array and bindParam/Array
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-9220@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=17286&edit=1 ID: 17286 Updated by: danielc@analysisandsolutions.com Reported By: martin dot edlman at gmail dot com Summary: Change of bindValue/Array and bindParam/Array Status: Open -Type: Bug +Type: Feature/Change Request Package: MDB2 Operating System: All Package Version: 2.5.0b2 PHP Version: 5.3.2 Roadmap Versions: New Comment: -Type: Bug +Type: Feature/Change Request Previous Comments: ------------------------------------------------------------------------ [2010-04-01 19:48:25] edlman Added #patch bug:17286;patch:MDB2-bindValue-bindParam;revision:1270151305;. ------------------------------------------------------------------------ [2010-04-01 19:46:46] 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 18:29:07] edlman Added #patch bug:17286;patch:modified-bindValue-and-bindValueArray;revision:1270146546;. ------------------------------------------------------------------------ [2010-04-01 18:25:06] 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) ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=17286&edit=1

« previous php.pear.bugs (#9220) next »