note 119531 added to mysqli-result.fetch-object

From: Date: Thu, 30 Jun 2016 14:57:00 +0000
Subject: note 119531 added to mysqli-result.fetch-object
Groups: php.notes 
Request: Send a blank email to php-notes+get-205847@lists.php.net to get a copy of this message
Note that if you supply a class that has a __set() magic method defined in it, that method will be called for any properties that are not defined in your class. For example: <?php class SomeClass { private $id; public $partner_name; public function __set( $name, $value ) { echo "__set was called! Name = $name\n"; $this->$name = $value; } } $db = new mysqli( 'localhost', 'Username', 'Password', 'DbName' ); $result = $db->query( 'SELECT id, partner_name, partner_type FROM submissions' ); $object = $result->fetch_object( 'SomeClass' ); ?> Produces the following output: __set was called! Name = partner_type ---- Server IP: 72.52.91.14 Probable Submitter: 173.224.163.75 ---- Manual Page -- http://php.net/manual/en/mysqli-result.fetch-object.php Edit -- https://master.php.net/note/edit/119531 Del: integrated -- https://master.php.net/note/delete/119531/integrated Del: useless -- https://master.php.net/note/delete/119531/useless Del: bad code -- https://master.php.net/note/delete/119531/bad+code Del: spam -- https://master.php.net/note/delete/119531/spam Del: non-english -- https://master.php.net/note/delete/119531/non-english Del: in docs -- https://master.php.net/note/delete/119531/in+docs Del: other reasons-- https://master.php.net/note/delete/119531 Reject -- https://master.php.net/note/reject/119531 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205847) next »