mysqli::bind_param(); variables

前端 未结 2 1768
遥遥无期
遥遥无期 2021-01-23 08:33
$mysqli = new mysqli(\'localhost\', \'my_user\', \'my_password\', \'world\');

/* check connection */
if (mysqli_connect_errno()) {
    printf(\"Connect failed: %s\\n\",         


        
相关标签:
2条回答
  • 2021-01-23 09:20

    Yes, because mysqli_stmt::bind_param: Binds variables to a prepared statement as parameters and it uses reference to these variables so that whenever you change them the change reflects on them.

    0 讨论(0)
  • 2021-01-23 09:25

    bind_param accepts references, if your unsure what references exactly are then click here for the extract named as "references explained"

    This does mean, it is valid to set your variables after the bind_param but then again, it's down to preference how you wish to do it. I for one, prefer declaring the variables prior to the bind

    Little observation

    The variables are declared prior to the execute, and as PHP works from top to bottom processing. When the variables are actully needed (on the execution) they would have already been set, if you declare your variables after the execute() you will be prompted with SQL Failures and other unwanted php errors

    0 讨论(0)
提交回复
热议问题