將我們的客戶網站之一移動到新的託管公司。
新的託管公司使用PHP 5.3.14
我在運行PHP 5.1.6的公司測試機器上測試了這個站點,並且一切正常。
然而,當我搬到現場,新的託管公司的服務器,它給了我下面的錯誤:
致命錯誤:調用未定義的方法DAOtemplate_Ex :: DAOparent_Ex()
致命錯誤:在/ var調用未定義的方法DAOtemplate_Ex :: DAOparent_Ex()/ www/html等/ nna_test /data/class_core/db/DAO_gate.php上線20
這是我的DAO_gate.php
<?php
require_once CLASS_CORE_EX_REALDIR . 'db_extends/DAOtemplate_Ex.php';
class DAO_gate extends DAOtemplate_Ex
{
function DAO_gate($value1="")
{
parent::DAOparent_Ex(); ---***LINE 20***---
$this->m_tablename = "dtb_gate";
$this->m_struct = array();
$this->m_struct_foreignKey = array();
$this->m_struct_foreignKey_target = array();
// get: table struct.
$this->CDB->SetQuery("show full columns from ". $this->m_tablename);
$this->CDB->ExecQuery();
while($row = $this->CDB->GetRecord()) {
$this->m_struct[] = $row;
}
$this->init();
}
.blah
.blah
.blah
}
和DAOtemplate_Ex其DAO_gate.php延伸是如下
<?php
// {{{ requires
require_once CLASS_CORE_REALDIR . 'db/DAOtemplate.php';
class DAOtemplate_Ex extends DAOtemplate
{
}
?>
DAOtemplate_Ex延伸DAOtemplate
<?php
require_once CLASS_CORE_EX_REALDIR . 'db_extends/DAOparent_Ex.php';
class DAOtemplate extends DAOparent_Ex
{
var $m_tablename;
var $m_struct;
var $m_struct_foreignKey;
var $m_struct_foreignKey_target;
function DAOtemplate($value1="")
{
parent::DAOparent_Ex();
$this->m_tablename = "";
$this->m_struct = array();
$this->m_struct_foreignKey = array();
$this->m_struct_foreignKey_target = array();
$this->CDB->SetQuery("show full columns from ". $this->m_tablename);
$this->CDB->ExecQuery();
while($row = $this->CDB->GetRecord()) {
$this->m_struct[] = $row;
}
$this->init();
}
.blah
.blah
.blah
}
DAOparent_Ex:
<?php
require_once CLASS_CORE_REALDIR . 'db/DAOparent.php';
class DAOparent_Ex extends DAOparent
{
}
?>
終於DAOparent:
<?php
require_once CLASS_CORE_REALDIR . 'db/SC_DBFactory.php';
class DAOparent
{
var $CDB;
var $m_use_sql;
function DAOparent()
{
if(empty($value1))
{
$this->CDB = SC_DBFactory::GetInstance(DB_TYPE);
$this->CDB->SetDBType(DB_TYPE);
$this->CDB->SetHost(DB_SERVER);
$this->CDB->SetDBName(DB_NAME);
$this->CDB->SetUserName(DB_USER);
$this->CDB->SetPassword(DB_PASSWORD);
$this->CDB->SetCharaCode(DB_ENCODING);
} else {
if(is_object($value1))
{
$this->CDB = $value1;
} else {
// error:
print("connect faild.");
die();
}
}
$this->CDB->Connect();
$this->m_use_sql = array("select", "update", "insert", "delete", "begin", "rollback");
$this->init();
}
function init()
{
}
.blah
.blah
.blah
}
有誰知道這個問題?
我以爲它是空的類的東西。
我很抱歉發佈這樣的長代碼。
我通過在DAOparent_Ex中創建一個構造函數並調用DAOparent構造函數來解決此問題。 謝謝JvdBerg – KOU