| 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: 'isss' For ($ I = 0; $ I <count ($ params); $ I ++ ){ // 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 $ Bind_names [] = & $ bind_name; // Now associate the variable as an 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 |