|
Private Function Bindvars ($stmt, $params) {
if ($params! = null) {
$types = "; Initial sting with types
foreach ($params as $param) {
For each element, determine type and add
if (Is_int ($param)) {
$types. = ' I '; Integer
} elseif (Is_float ($param)) {
$types. = ' d '; Double
} elseif (Is_string ($param)) {
$types. = ' s '; String
} else {
$types. = ' B ';
Blob and unknown
}
}
$bind _names[] = $types;
First param needed is the type string
Eg: ' Issss '
for ($i =0; $i < p="">
Go through incoming params and added em to array
$bind _name = ' bind '. $i;
Give them an arbitrary name
$ $bind _name = $params [$i];
Add the parameter to the variable variable
$bind _names[] = &$ $bind _name;
Now associate the variable as a element in an array
}
Call the function Bind_param with dynamic params
Call_user_func_array (Array ($stmt, ' Bind_param '), $bind _names);
}
return $stmt; Return the bound statement
|