note 92784 added to mysqli-result.fetch-object

From: Date: Sun, 09 Aug 2009 03:04:09 +0000
Subject: note 92784 added to mysqli-result.fetch-object
Groups: php.notes 
Request: Send a blank email to php-notes+get-159223@lists.php.net to get a copy of this message
I don't know why no one talk about this. fetch_object is very powerful since you can instantiate an Object which has the methods you wanna have. You can try like this.. class PowerfulVO extends AbstractWhatEver { public $field1; private $field2; // note : private is ok public function method(){ // method in this class } } $sql = "SELECT * FROM table ..." $mysqli = new mysqli(........); $result = $mysqli->query($sql); $vo = $result->fetch_object('PowerfulVO'); Note : if the field is not defined in the class, fetch_object will add this field for you as public. The method is very powerful, especially if you want to use a VO design pattern or class mapping feature with Flex Remoting Object( Of course, you need to have ZendAMF or AMFPHP ..framework) Hope this help and open new possibilities for you ---- Server IP: 69.147.83.197 Probable Submitter: 222.90.89.219 ---- Manual Page -- http://www.php.net/manual/en/mysqli-result.fetch-object.php Edit -- https://master.php.net/note/edit/92784 Del: integrated -- https://master.php.net/note/delete/92784/integrated Del: useless -- https://master.php.net/note/delete/92784/useless Del: bad code -- https://master.php.net/note/delete/92784/bad+code Del: spam -- https://master.php.net/note/delete/92784/spam Del: non-english -- https://master.php.net/note/delete/92784/non-english Del: in docs -- https://master.php.net/note/delete/92784/in+docs Del: other reasons-- https://master.php.net/note/delete/92784 Reject -- https://master.php.net/note/reject/92784 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159223) next »