note 114652 added to pdostatement.fetchobject
| From: | VegardLkken | Date: | Tue, 18 Mar 2014 07:19:46 +0000 |
| Subject: | note 114652 added to pdostatement.fetchobject | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198953@lists.php.net to get a copy of this message | ||
Because of the injection of object properties before the constructor is executed, I usually build my
classes like this to make sure already set properties aren't overwritten:
<?php
class Person {
public $name;
public $age;
public $sex;
public function __construct($name=NULL, $age=NULL, $sex=NULL) {
$this->name = $name === NULL ? $this->name : $name;
$this->age = $age === NULL ? $this->age : $age;
$this->sex = $sex === NULL ? $this->sex : $sex;
}
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 195.18.128.186
----
Manual Page -- http://php.net/manual/en/pdostatement.fetchobject.php
Edit -- https://master.php.net/note/edit/114652
Del: integrated -- https://master.php.net/note/delete/114652/integrated
Del: useless -- https://master.php.net/note/delete/114652/useless
Del: bad code -- https://master.php.net/note/delete/114652/bad+code
Del: spam -- https://master.php.net/note/delete/114652/spam
Del: non-english -- https://master.php.net/note/delete/114652/non-english
Del: in docs -- https://master.php.net/note/delete/114652/in+docs
Del: other reasons-- https://master.php.net/note/delete/114652
Reject -- https://master.php.net/note/reject/114652
Search -- https://master.php.net/manage/user-notes.php