Ich tue dies hier:dynamisch richtige Anzahl von Parametern Klasse Konstruktor
public function fetch($className)
{
$rows = array();
while($r = $this->result->fetch_object() {
$rows[] = new $className($r);
}
return $rows;
}
Constructor
class User
{
public $dbh;
public $row;
public function __construct($dbh, $row = null)
{
$this->dbh = $dbh;
$this->row = $row;
}
public function getAll()
{
return $this->dbh->query('SELECT * FROM users')->fetchAll();
}
public function getFirstName()
{
return $this->row->first_name;
}
}
Das ist alles gut und gut, wenn meine Klasse Konstruktor hat nur einen Parameter.
Wie mache ich das dynamisch, damit ich andere Parameter in meinem Konstruktor haben kann. Hoffe, das macht Sinn.
Jede Hilfe wäre genial :-)
wo ist Ihre Konstrukt-Funktion – Akintunde007
hinzugefügt @Akintunde – Programit