【发布时间】:2015-10-30 11:58:15
【问题描述】:
【问题讨论】:
【问题讨论】:
注入它:
class general{
public function __construct(db $db){
$this->db = $db;
}
public function userId($nickname) {
$result = $this->db->query('SELECT `id` FROM `users` WHERE `username` = $nickname'); //there i want to call to db class
return($this->db->fetch($result));
}
}
后来:
$db = new db();
$general = new general($db);
【讨论】: