Set MySQL Variables with MySQLi (not PHP variables)

后端 未结 1 1665
轻奢々
轻奢々 2020-12-22 01:15

It\'s work with PHP variables:

Prepearing one result from query function

   extract($GLOBALS);
   $GLOBALS[\'mysqli\'] = $mysqli;

function select($a         


        
相关标签:
1条回答
  • 2020-12-22 01:22

    You've got to use a user defined variable:

    User-Defined Variables

    You can store a value in a user-defined variable in one statement and then refer to it later in another statement. This enables you to pass values from one statement to another. User-defined variables are session-specific. That is, a user variable defined by one client cannot be seen or used by other clients. All variables for a given client session are automatically freed when that client exits.

    User variables are written as @var_name, where the variable name var_name consists of alphanumeric characters, “.”, “_”, and “$”. A user variable name can contain other characters if you quote it as a string or identifier (for example, @'my-var', @"my-var", or @my-var).

    $query .= "SET @other = $other;"; // return: Unknown system variable 'other'
    
    0 讨论(0)
提交回复
热议问题