【发布时间】:2018-06-18 13:32:15
【问题描述】:
当我尝试访问我的库的功能时遇到此错误: 遇到 PHP 错误
严重性:通知
消息:未定义的属性:ControllerUser::$alertClasse
文件名:控制器/ControllerUser.php
行号:183
回溯:
文件: C:\wamp64\www\logistock\application\controllers\ControllerUser.php 行:183 函数:_error_handler
文件: C:\wamp64\www\logistock\application\controllers\ControllerUser.php 行:22 函数:call_user_func_array
文件:C:\wamp64\www\logistock\index.php 行:315 功能: 需要一次
这是我的图书馆:
defined('BASEPATH') OR exit('No direct script access allowed');
class AlertClasse
{
protected $CI;
public function __construct()
{
$this->CI =& get_instance();
$this->CI->load->model('AlerteModel');
}
public function stockSeuil()
{
$query=$this->CI->AlerteModel->getarticles();
$tabStockSeuil = array();
foreach($query as $tab)
{
if($tab->art_solde<=$tab->seuil_alert_art)
{
$article[] = $tab->id_art;
$article[] = $tab->lib_art;
$article[] = $tab->art_solde;
$article[] = $tab->seuil_alert_art;
$article[] = $tab->perissable;
$tabStockSeuil[] = $article;
$article = array();
}
}
return $tabStockSeuil;
}
public function stockExpire()
{
$query=$this->CI->AlerteModel->get_art_lot();
$tabartexpire = array();
$datejour = date('d/m/Y');
$djour = explode("/", $datejour);
$auj = mktime(00, 00, 00,$djour["1"],$djour["0"],$djour["2"]);
foreach($query as $tab)
{
if($tab->date_expir!=0)
{
$datexpiration= $tab->date_expir;
if ($auj>=$datexpiration)
{
$id = $tab->id_lot;
$artexpire[] = $tab->lib_art;
$artexpire[] = $tab->qte_lot;
$artexpire[] = $tab->date_enregistrement;
$artexpire[] = $tab->date_expir;
$tabartexpire[] =$artexpire;
$this->articles_model->mis_au_rebut($id);
$artexpire = array();
}
}
}
return $tabartexpire;
}
public function ExpireProche()
{
$query=$this->CI->AlerteModel->get_art_lot();
$tabartexpire = array();
$datejour = date('d/m/Y');
$djour = explode("/", $datejour);
$auj = mktime(00, 00, 00, $djour["1"], $djour["0"], $djour["2"]);
$nextDat =time() + (5 * 24 * 60 * 60);
$temp =date('d/m/Y', $nextDat);
$temp = explode("/", $temp);
$nextDate = mktime(00, 00, 00, $temp["1"],$temp["0"],$temp["2"]);
foreach($query as $tab)
{
if($tab->date_expir!=0)
{
$datexpiration= $tab->date_expir;
if (intval($auj)<intval($datexpiration) && intval($nextDate) >=
intval($datexpiration))
{
$artexpire[] = $tab->lib_art;
$artexpire[] = $tab->qte_lot;
$artexpire[] = $tab->date_enregistrement;
$artexpire[] = $tab->date_expir;
// On met ensuite le résultat obtenu dans un tableau
$tabartexpire[] =$artexpire;
$artexpire = array();
}
}
}
return $tabartexpire;
}
}
在我的控制器中:
defined('BASEPATH') OR exit('No direct script access allowed');
class ControllerUser extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->library('alertClasse');
$this->load->database();
$this->load->library('session');
}
}
这里我尝试访问该方法:
public function affichageUser(){
//error here
$tabExpirProch = $this->alertClasse->ExpireProche();
$priv = $this->UserModel->getpriv();
$this->load->view('users/listUser',['privilege'=>$priv]);
}
【问题讨论】:
标签: php codeigniter