I am getting below error when trying to load model in a controller Fatal error: Class 'Admin_Model_Adminlogin' not found in /var/www/html/ZendTecAdmin/application/controllers/AdminController.php on line 27
Below is the controller AdminController.php
<?php
class AdminController extends Zend_Controller_Action {
public function init() {
$this->_helper->layout->setLayout('layout_admin');
//$this->view->headScript()->appendFile($view->getBaseUrl.'js/jquery-1.10.2.min.js');
//$this->view->headScript()->appendFile($view->getBaseUrl.'js/validate.js');
}
public function indexAction() {
echo 'Welcome';
}
public function loginAction() {
$mysession = new Zend_Session_Namespace('Admin');
$form = new Application_Form_loginForm();
$this->view->form = $form;
//Preform Admin login action
if($this->_request->getPost('Login')){
$formData=$this->_request->getPost();
if($form->isValid($formData)){ //If form data is valid
$name=$this->_request->getPost('username');
$password=$this->_request->getPost('password');
/****Creating object of model adminlogin class*****/
$adminLoginObj=new Admin_Model_Adminlogin();
$fetchResult=$adminLoginObj->checkAdminAuthority($name,$password);
if(count($fetchResult)>0){
$mysession->adminName=$name;
$this->_redirect('/admin/');
}else{
$mysession->failLogin="Invalid Username or Password!";
$this->_redirect('/admin/login');
}
}
}
}
}
Following is Application.ini
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "root123"
resources.db.params.dbname = "quickstat"
resources.db.isDefaultTableAdapter = true
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.frontController.baseUrl = "/ZendTecAdmin/"
resources.session.remember_me_seconds = 864000
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
resources.db.params.profiler.enabled = true
resources.db.params.profiler.class = Zend_Db_Profiler_Firebug
includePaths.models = APPLICATION_PATH "/models/"
And model application/models/Admin.php
<?php
class Admin_Model_Adminlogin extends Zend_Db_Table{
/* The Model Class Will be associated with register table*/
protected $_name='users';
function checkAdminAuthority($name,$pasword){
$where="username='".$name."' and password='".$pasword."'";
return $row=$this->fetchRow($where);
}
}
Please help me to resolve this issue.
如果您的模型是模型application / models / Admin.php,则该模型的类名应为
class Admin_Model_Admin
您的模型扩展了Zend_Db_table,它应该扩展了Zend_Db_Table_Abstract
class Admin_Model_Adminlogin extends Zend_Db_Table_Abstract{
请尝试以下代码来创建模型对象:
$adminLoginObj = new Application_Model_Adminlogin();
Please update file name and class name as below,
File name : AdminLogin.php
Class name : Application_Model_Adminlogin
class Application_Model_Adminlogin extends Zend_Db_Table{
Create object as
$adminLoginObj = new Application_Model_Adminlogin();
I hope this will help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.