note 92287 modified in mysqli-stmt.bind-result by danbrown

From: Date: Fri, 17 Jul 2009 16:30:07 +0000
Subject: note 92287 modified in mysqli-stmt.bind-result by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158425@lists.php.net to get a copy of this message
Took some cool code from here and made a little class for those object oriented kind of guys used like this: <?php // execute prepared statement $stmt->execute(); $stmt->store_result(); //custom class :D bind to Statement Result mambo jambo! $sr = new Statement_Result($stmt); $stmt->fetch(); printf("ID: %d\n", $sr->Get('id') ); ///////////////////////////////// class Statement_Result { private $_bindVarsArray = array(); private $_results = array(); public function __construct(&$stmt) { $meta = $stmt->result_metadata(); while ($columnName = $meta->fetch_field()) $this->_bindVarsArray[] = &$this->_results[$columnName->name]; call_user_func_array(array($stmt, 'bind_result'), $this->_bindVarsArray); $meta->close(); } public function Get_Array() { return $this->_results; } public function Get($column_name) { return $this->_results[$column_name]; } } ?> --was-- Took some cool code from here and made a little class for those object oriented kind of guys used like this: // execute prepared statement $stmt->execute(); $stmt->store_result(); //custom class :D bind to Statement Result mambo jambo! $sr = new Statement_Result($stmt); $stmt->fetch(); printf("ID: %d\n", $sr->Get('id') ); ///////////////////////////////// class Statement_Result { private $_bindVarsArray = array(); private $_results = array(); public function __construct(&$stmt) { $meta = $stmt->result_metadata(); while ($columnName = $meta->fetch_field()) $this->_bindVarsArray[] = &$this->_results[$columnName->name]; call_user_func_array(array($stmt, 'bind_result'), $this->_bindVarsArray); $meta->close(); } public function Get_Array() { return $this->_results; } public function Get($column_name) { return $this->_results[$column_name]; } } http://php.net/manual/en/mysqli-stmt.bind-result.php

« previous php.notes (#158425) next »