Jump to content

Nested Functions


epseix1
Go to solution Solved by requinix,

Recommended Posts

The following code:

 

$stmt->bind_param('s', $strId);
How can I define EVERYTHING within the brackets as a single function as opposed to 2 separate variables?

 

Can't seem to get syntax quite right...

 

... Is there a better method for storing all prepared statement variables, or all stmt code, in a separate "include" file using nested functions?

 

All advice greatly appreciated?

Link to comment
Share on other sites

  • Solution

bind_param() needs a variable reference for the second argument. It's not as simple as just using an array.

 

Example:

$arr = array('');

$arr[0] .= 's';
$arr[] =& $strId;

$arr[0] .= 'i';
$arr[] =& $intFoo;

$arr[0] .= 's';
$arr[] =& $strBar;

call_user_func_array(array($stmt, 'bind_param'), $arr); // the magic happens here
call_user_func_array
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.