Use of undefined constant DB - assumed 'DB'

public function base(){
$base = Config::get('app.base');
$baseURL = Config::get('app.baseURL');
$etw = App::make('ETW');
$check = App::make('Check');
$username = Session::get('username');
$password = Session::get('password');
$check->checkLogin($etw,DB,$username,$password,$baseURL);
$navertype = '2015/base';
$label = DB::table('db_naver')->select('label','showtxt','links')->where('nav_type',$navertype)->orWhere('nav_type','2015/login_base')->get();
$htmlLabel = array();
foreach($label as $key=>$val)
{
$htmlLabel[$val->label]['label'] = $val->showtxt;
$htmlLabel[$val->label]['links'] = $val->links;
}
return View::make('login.login',compact('htmlLabel'));
}

我在调用时传值时
$check->checkLogin($etw,DB,$username,$password,$baseURL);
提示DB无效,没有定义,请问有知道原因的吗?
已邀请:
匿名用户

匿名用户

赞同来自:

你们out啦
<?php
class Check{
public function checkLogin($etw,$DB,$username,$password,$location){
$user = $DB::table('g_name')->select('gstate','username','password','editable')->where(array('username'=>$username,'password'=>$password))->get();
if(sizeof($user)<1)
{
echo '<a href="'.$location.'">BACK</a>';
exit();
}
}
}
?>
在这个地方接收常量,并且是没有问题的,我只是在程序开部部分忘记屏蔽警告信息而己了
匿名用户

匿名用户

赞同来自:

很多查询以及数据库的具体操作不想放在主程序里(避免主程序过于冗长,保证主程序简洁),而是放在自定义的一个类里面,在另一个自定义的类里面便用

不过本人的习惯造成的错误,喜欢传值,其实在这儿是可以不用传值的,DB似乎是一个程序级的常量,不需要传值的,深表报歉
匿名用户

匿名用户

赞同来自:

常量是不需要传值的,这个在平常的程序中一直没有注意这个问题,新手,呵呵

FiveSay - 成武

赞同来自:

怎么会有这么奇葩的代码 ..
你是要传 DB 这个常量吗?

王赛

赞同来自:

基本知识该补补了

00幽靈00 - 略知一二,不求甚解

赞同来自:

从语法学起,别着急……

要回复问题请先登录注册