如何将查询结果中的值转换为变量和变量值?

I'm trying to pull two columns from my database and turn the column1 value into the variable name and the value from column2 into the variable value. Like this:

column1 | column2

value1 | value2

value3 | value4

The result should be: 
$value1 = "value2"
$value3 = "value4"
etc..

Is there any way to achieve this with one singe query?

You can achieve it by php code,

$query = "SELECT col1, col2 FROM test";

if($result = mysqli_query($conn, $query)) {

/* fetch associative array */
while ($row = mysqli_fetch_assoc($result)) {
    ${$row['col1']} = $row['col2'];
}

echo $val1;     // Echos val2
echo "<br />";
echo $val3;     // Echos val4
/* free result set */
mysqli_free_result($result);