迷ってみたり
例1
<?php class Employee { private $db; private $name; private $position; function __construct(&$db) { $this->db =& $db; } function setName($name) { $this->name = $name; } function setPosition($position) { $this->position = $position; } function create() { // create } function destroy() { // destroy } } $employee = new Employee(DBobj); $employee->setName('nameA'); $employee->setPosition('regular'); $employee->create(); ?>
例2
<?php class Employee { private $name; private $position; function setName($name) { $this->name = $name; } function setPosition($position) { $this->position = $position; } function create(&$dbobj) { // create } function destroy(&$dbobj) { // destroy } } $employee = new Employee; $employee->setName('nameA'); $employee->setPosition('regular'); $employee->create(DBobj); ?>
個人的には例2の方が好きなんだけどなあ。