0

我创建了一个包含类的文件夹。我正在尝试访问控制器中该文件夹中类的返回。

提前致谢

模型类GetUserPersonalData及其位于此处:

E:\wamp\www\ZendEbayApp\module\Application\src\Application\models

我的控制器位于此处:

E:\wamp\www\ZendEbayApp\module\Application\src\Application\Controller

后端用户管理控制器.php

    <?php

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;

class BackendUserAdministrationController extends AbstractActionController {

    public function indexAction() {
        $this->layout('layout/BackendAdministrationLayout');
    }

    public function AddAdditionalUserAcountsAction() {
        $this->layout('layout/BackendAdministrationLayout');

        $GetUserPersonalDataClassObject = new \Application\models\GetUserPersonalDataClass();
        $theoutputarray = $GetUserPersonalDataClassObject->GetUserPersonalDatafunction();
        echo $theoutputarray[1];
    }

    public function AddCompanyDetailAction() {
        $this->layout('layout/BackendAdministrationLayout');
    }

    public function AddUserAccountAction() {
        $this->layout('layout/BackendAdministrationLayout');
    }

    public function AddUserPersonalAction() {
        $this->layout('layout/BackendAdministrationLayout');
    }

    public function AddUserPlanDetailAction() {
        $this->layout('layout/BackendAdministrationLayout');
    }

    public function AddUserPreferencesAction() {
        $this->layout('layout/BackendAdministrationLayout');
    }

    public function AddUserTransactionsAction() {
        $this->layout('layout/BackendAdministrationLayout');
    }

}

获取用户个人数据.php

    <?php

class GetUserPersonalDataClass {

    public function GetUserPersonalDatafunction() {

        $GetUserPersonalDataArray = array();

        $OpenedUserPersonalFile = fopen("E:/wamp/www/ZendEbayApp/data/usersinformation/userPersonal.txt", "r");
        while (!feof($OpenedUserPersonalFile)) {
            $OpenedUserPersonalFileSingleRow = fgets($OpenedUserPersonalFile);

            array_push($GetUserPersonalDataArray, "$OpenedUserPersonalFileSingleRow");
        }
        fclose($OpenedUserPersonalFile);

        return $GetUserPersonalDataArray;
    }

}

$GetUserPersonalDataClassObject = new GetUserPersonalDataClass();
$theoutputarray =  $GetUserPersonalDataClassObject->GetUserPersonalDatafunction();

echo $theoutputarray[1];
?>

当我使用 betbeans 调试 BackendUserAdministrationController.php 时,它还说:

        E:\wamp\bin\php\php5.4.3\php.exe E:\wamp\www\ZendEbayApp\module\Application\src\Application\Controller\BackendUserAdministrationController.php

    Fatal error: Class 'Application\Controller\AbstractActionController' not found in E:\wamp\www\ZendEbayApp\module\Application\src\Application\Controller\BackendUserAdministrationController.php on line 7

    Call Stack:
        0.0013     130104   1. {main}() E:\wamp\www\ZendEbayApp\module\Application\src\Application\Controller\BackendUserAdministrationController.php:0

    PHP Fatal error:  Class 'Application\Controller\AbstractActionController' not found in E:\wamp\www\ZendEbayApp\module\Application\src\Application\Controller\BackendUserAdministrationController.php on line 7
    PHP Stack trace:
    PHP   1. {main}() E:\wamp\www\ZendEbayApp\module\Application\src\Application\Controller\BackendUserAdministrationController.php:0
    Done.
4

2 回答 2

0

您的类似乎没有命名空间,这可能会解释问题,请尝试添加一个

<?php
// add this line to your model class
namespace Application\models;

class GetUserPersonalDataClass
{
    // <snipped/>
}
于 2013-04-10T03:24:05.987 回答
0

而不是类,创建一个库文件,也许这可以帮助:

如何访问自定义文件的数据库

于 2013-04-10T08:46:34.967 回答