我有两个类,都在不同的命名空间中。当我尝试从一个命名空间创建对象时,我得到了错误
Fatal error: Class 'Classes\DrDatabase' not found in C:\Path\to\workspace\AplicationName\app\models\Users.model.php on line XY
php命名空间有什么我不明白的吗?
两个文件:
FILE 1
namespace Classes;
class DrDatabase extends MssqlDatabase {
public function __construct() {
parent::createLog(__CLASS__);
parent::connect('ipaddress', 'database', 'user', 'password');
if ($this->link) {
$this->log->info('Connected');
}
}
}
FILE 2
namespace Model;
use \Classes\DrDatabase;
class UsersModel implements MasterModel {
private function get($id, $onlyEnabled) {
$db = new DrDatabase();
$getOnlyEnabled = 1;
if (!$onlyEnabled)
$getOnlyEnabled = 0;
$SQL = "SELECT * FROM table";
$resultSet = $db->query($SQL);
$result = array();
while ($row = mssql_fetch_assoc($resultSet)) {
$result[] = self::createUserObject($row['col1'],$row['col2']);
}
}
}