Web lists-archives.com

[PHP] Re: Problem with mysqli_bind_param




Thank you, I was suspecting something like that was happening, but i found
nothing in my searchs so I was just clearing the issue.

Was very enlightening :)

On Mon, Jan 30, 2017 at 3:37 PM, Christoph M. Becker <cmbecker69@xxxxxx>
wrote:

> On 30.01.2017 at 16:22, Diogo Neves wrote:
>
> > I don't know if its a bug, a feature or just me being idiotic ( i don't
> > really discarded that yet )... but...
> >
> > This is a small piece of my code.
> >
> >         if ( !empty( $types )) {
> >             $tmp = Array( $types );
> >             foreach( $array as $key => $value ) {
> >                 $tmp[] = &$array[ $key];
> >             }
> >
> >             call_user_func_array( array( $stmt, 'bind_param' ), $tmp );
> >         }
> >
> > My problem was i get NULL on return of call_user_func_array... i tracked
> it
> > back to $stmt->bind_param( $types, $array[0], $array[1], $array[2] );
> >
> > Then after all and some reading i found i was screwing up, yet, returning
> > null should be the right return?
> >
> > I ask because it says nothing about NULL on
> > http://php.net/manual/en/mysqli-stmt.bind-param.php. Yet if i send
> > something that isn't a string in $types ( my screw up, anyway ) it don't
> > return false as i expected.
>
> From the PHP manual[1]:
>
> | If the parameters given to a function are not what it expects, such
> | as passing an array where a string is expected, the return value of
> | the function is undefined. In this case it will likely return NULL
> | but this is just a convention, and cannot be relied upon.
>
> This behavior is deliberately not documented for each individual
> built-in function.
>
> [1] <http://php.net/manual/en/functions.internal.php>
>
> --
> Christoph M. Becker
>
>