Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
class Result {
private $columnNames = [];
private $boundValues = [];
public function __construct(mysqli $mysqli){
$stmt = $mysqli->prepare('SELECT 1 as `asd`,23 as `a`,4 as `bcvbvc`');
$stmt->execute();
$stmt->store_result();
$meta = $stmt->result_metadata();
$this->columnNames = array_column($meta->fetch_fields(), 'name');
$this->boundValues = array_fill(0, count($this->columnNames), null);
$stmt->bind_result(...$this->boundValues);
$stmt->fetch();
var_dump($this->boundValues);
}
}
new Result($mysqli);