Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?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);
Copy Clear