0
我嘗試使用ajax進行admin登錄。但是我運行進入這個錯誤。我不知道列0從哪裏來。SQLSTATE [42S22]:未找到列:1054'where子句'中的未知列'0'(SQL:select * from users where 0 = admin limit 1)
SQLSTATE [42S22]:柱未找到:1054未知列 '0' '其中 子句'(SQL:SELECT * FROM
users
其中0
=管理員極限1)
這是我的代碼
public function login()
{
$username= Input::get('username');
$password= Input::get('password');
$admin=array([
'username'=>$username,
'password'=>$password,
'level'=>1
]);
if ($this->auth->attempt($admin)) {
return "ok";
}
else {
return "fail";
}
}
型號
<?php namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
class User extends Model implements AuthenticatableContract
{
use Authenticatable;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ["username","password",'level'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password'];
public $timestamps = false;
}
添加完整的錯誤堆棧中的問題。 – Vikas
@Vikas我剛剛更新了錯誤 –