0
class Event extends DB_CONNECTION {
private $EVNT_ID;
private $Organizer;
private $name;
private $venue;
private $discription;
private $picture;
private $Address;
private $start_datetime;
private $end_datetime;
private $category;
private $topic;
private $Ticket;
private $Sponsor;
private $Special_guest;
private $active;
function __construct(Organizer $org) {
$this->Organizer = $org;
$this->Ticket = Ticket::get_tickets($this);
$this->Sponsor = new Sponsor($this);
parent::__construct();
}
}
public function fetch_events() {
$sql = "SELECT * ";
$sql .= "FROM `event` ";
$sql .= " ORDER BY `EVNT_ID` DESC LIMIT 21 ";
$this->data_set = self::query($sql);
$this->data_set->setFetchMode(PDO::FETCH_CLASS, 'Event');
$events = $this->data_set->fetchAll();
return (isset($events)) ? $events : false;
}
這是我的事件類的構造函數旁路PDO構造函數獲取參數錯誤
目前正在開發使用PHP和PDO爲數據庫連接事件管理系統。
我選擇PDO爲它取模式選項,以初始化SQL查詢對象。但得到一個構造函數錯誤。
因爲PDO取出由該類數據時發出"cannot recreate __construct "
錯誤,我不能用我的構造函數的參數。
是否有辦法繞過這個?或者我應該改變我的類的結構和使用init()
函數來初始化我的對象,而不是使用__constructor的?
什麼確切的角色扮演PDO這裏,你有什麼整體的設計或者什麼行代碼觸發錯誤目前尚不清楚。您能否編輯該問題並分享重現該問題的有效代碼? –