note 81350 added to function.mysqli-stmt-bind-result

From: Date: Sat, 23 Feb 2008 23:24:41 +0000
Subject: note 81350 added to function.mysqli-stmt-bind-result
Groups: php.notes 
Request: Send a blank email to php-notes+get-136446@lists.php.net to get a copy of this message
Although inspired by an earlier post, this method could be added to any of your database objects. It's an object oriented implementation of an earlier post. The method returns an array with objects representing a row. Each property represents a column and its value. <?php private function getresult($stmt) { $result = array(); $metadata = $stmt->result_metadata(); $fields = $metadata->fetch_fields(); for (;;) { $pointers = array(); $row = new stdClass(); $pointers[] = $stmt; foreach ($fields as $field) { $fieldname = $field->name; $pointers[] = &$row->$fieldname; } call_user_func_array(mysqli_stmt_bind_result, $pointers); if (!$stmt->fetch()) break; $result[] = $row; } $metadata->free(); return $result; } ?> ---- Server IP: 213.249.64.162 Probable Submitter: 82.95.138.10 ---- Manual Page -- http://www.php.net/manual/en/function.mysqli-stmt-bind-result.php Edit -- https://master.php.net/note/edit/81350 Del: integrated -- https://master.php.net/note/delete/81350/integrated Del: useless -- https://master.php.net/note/delete/81350/useless Del: bad code -- https://master.php.net/note/delete/81350/bad+code Del: spam -- https://master.php.net/note/delete/81350/spam Del: non-english -- https://master.php.net/note/delete/81350/non-english Del: in docs -- https://master.php.net/note/delete/81350/in+docs Del: other reasons-- https://master.php.net/note/delete/81350 Reject -- https://master.php.net/note/reject/81350 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136446) next »