PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
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);
Show:  
Copy Clear