tags:

views:

22

answers:

1

I found the following code on php.net. I'm trying to write a wrapper for the MySQLi library to make things incredibly simple. If this is going to slow down performance, I'll skip it and find another way, if this works, then I'll do that.

I have a single query function, if someone passes in more than one variable, I assume the function has to be prepared. The function that I would use to pass in an array to mysqli_stmt_bind_param is call_user_func_array, I have a feeling that is going to slow things down. Am I right?

<?php
/* just explaining how to call mysqli_stmt_bind_param with a parameter array */

$sql_link = mysqli_connect('localhost', 'my_user', 'my_password', 'world');
$type = "isssi";
$param = array("5", "File Description", "File Title", "Original Name", time());
$sql = "INSERT INTO file_detail (file_id, file_description, file_title, file_original_name, file_upload_date) VALUES (?, ?, ?, ?, ?)";
$sql_stmt = mysqli_prepare ($sql_link, $sql);
call_user_func_array('mysqli_stmt_bind_param', array_merge (array($sql_stmt, $type), $param);
mysqli_stmt_execute($sql_stmt);
?>
+1  A: 

Nope. You're wrong.
1 call_user_func_array call can never be the performance bottle neck.
So if it performed slow - then your query runs slow.

zerkms
This is in a wrapper, class 4-8 calls will be called per page, and possibly 30-50 pages, by potentially hundreds of thousands of users. Won't make a difference?
Kerry
number of users will not change anything. dozen of php function calls (just calls, not their execution) will always be **much** faster than query execution.
zerkms