note 130381 added to mysqli-stmt.get-result

From: Date: Sat, 21 Jun 2025 19:21:48 +0000
Subject: note 130381 added to mysqli-stmt.get-result
Groups: php.notes 
Request: Send a blank email to php-notes+get-222232@lists.php.net to get a copy of this message
<?php // This is my simple way to load an unique data. // Load cliente - return my cliente id,nome and email. // Connect to Mysqli $mysqli = new mysqli("localhost", "my_user", "my_password", "clientes"); // Prepare your query $stmt = $mysqli->prepare("SELECT id, nome, email FROM clientes WHERE id = ?"); // Set your cliente id to load $id = 1; $stmt->bind_param('i', $id); // Execute your query $stmt->execute(); // Get result $result = $stmt->get_result(); // Fetch your rows into array $rows = $result->fetch_array(); $data = array(); // Combine the fields of your table with your rows array result. while($field = $result->fetch_field()) { $data[$field->name] = $rows[$field->name]; } // Close the dataset $stmt->close(); // Debug to see data return echo "<pre>"; print_r($data); echo "</pre>"; // I hope I helped! // Julio Leles (julio.necronomicon@gmail.com) ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 2804:14c:5b80:8141:f97f:6b45:e6db:5a15) ---- Manual Page -- https://php.net/manual/en/mysqli-stmt.get-result.php Edit -- https://main.php.net/note/edit/130381 Del: integrated -- https://main.php.net/note/delete/130381/integrated Del: useless -- https://main.php.net/note/delete/130381/useless Del: bad code -- https://main.php.net/note/delete/130381/bad+code Del: spam -- https://main.php.net/note/delete/130381/spam Del: non-english -- https://main.php.net/note/delete/130381/non-english Del: in docs -- https://main.php.net/note/delete/130381/in+docs Del: other reasons-- https://main.php.net/note/delete/130381 Reject -- https://main.php.net/note/reject/130381 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#222232) next »