@@ -158,7 +158,7 @@ public function prepareParameterKeyMapping($sql)
158158 $ quoteChar = '' ;
159159 $ literal = '' ;
160160 $ mapping = [];
161- $ replace = [] ;
161+ $ position = 0 ;
162162 $ matches = [];
163163 $ pattern = '/([:][a-zA-Z0-9_]+)/ ' ;
164164
@@ -197,16 +197,15 @@ public function prepareParameterKeyMapping($sql)
197197 $ literal .= substr ($ substring , 0 , $ match [1 ]);
198198 }
199199
200- if (isset ($ mapping [$ match [0 ]])) {
201- $ mapping [$ match [0 ]] = is_array ($ mapping [$ match [0 ]]) ? $ mapping [$ match [0 ]] : [$ mapping [$ match [0 ]]];
202- $ mapping [$ match [0 ]][] = \count ($ mapping );
203- } else {
204- $ mapping [$ match [0 ]] = \count ($ mapping );
200+ if (!isset ($ mapping [$ match [0 ]])) {
201+ $ mapping [$ match [0 ]] = [];
205202 }
206- $ endOfPlaceholder = $ match [1 ] + strlen ($ match [0 ]);
203+
204+ $ mapping [$ match [0 ]][] = $ position ++;
205+ $ endOfPlaceholder = $ match [1 ] + strlen ($ match [0 ]);
207206 $ beginOfNextPlaceholder = $ matches [0 ][$ i + 1 ][1 ] ?? strlen ($ substring );
208207 $ beginOfNextPlaceholder -= $ endOfPlaceholder ;
209- $ literal .= '? ' . substr ($ substring , $ endOfPlaceholder , $ beginOfNextPlaceholder );
208+ $ literal .= '? ' . substr ($ substring , $ endOfPlaceholder , $ beginOfNextPlaceholder );
210209 }
211210 } else {
212211 $ literal .= $ substring ;
@@ -378,14 +377,9 @@ public function execute(?array $parameters = null)
378377 foreach ($ this ->bindedValues as $ key => &$ value ) {
379378 $ paramKey = $ this ->parameterKeyMapping [$ key ];
380379
381- if (is_scalar ($ this ->parameterKeyMapping [$ key ])) {
382- $ params [$ paramKey ] =& $ value ;
383- $ types [$ paramKey ] = $ this ->typesKeyMapping [$ key ];
384- } else {
385- foreach ($ paramKey as $ currentKey ) {
386- $ params [$ currentKey ] =& $ value ;
387- $ types [$ currentKey ] = $ this ->typesKeyMapping [$ key ];
388- }
380+ foreach ($ paramKey as $ currentKey ) {
381+ $ params [$ currentKey ] =& $ value ;
382+ $ types [$ currentKey ] = $ this ->typesKeyMapping [$ key ];
389383 }
390384 }
391385 } else {
0 commit comments