獲得一個:分貝類功能無法識別
Fatal error: Call to undefined method UsersController::select() application/models/User.php on line 27
它看起來像UsersController不發送選擇功能,我有一個庫文件夾中的db.class.php。
db.class.php正在加載,但不是在這種情況下。在UserController.php類中
代碼:
class User extends Model
{
/**
* Login method
*
* @todo: update last_login_time
* @todo: add hashing
*/
public function user_login() {
$username = $_POST['data']['User']['username'];
$password = $_POST['data']['User']['password'];
$bind = array(
":username" => $username,
);
$result = $this->select("users", "username = :username", $bind);
//Check the password returned from the db against the password entered
if (Bcrypt::checkPassword($password, $result[0]['password']) == true) {
Session::init();
Session::set('user_logged_in', true);
Session::set('user_id', $result[0]['id']);
Session::set('user_name', $result[0]['username']);
Session::set('user_permission', $result[0]['permission']);
Session::set('user_role', $result[0]['role']);
return true;
} else {
return false;
}
}
/**
* Log out process, deletes cookie, deletes session
*
* @todo implement rememberme cookie
*/
public function logout()
{
// set the remember-me-cookie to ten years ago (3600sec * 365 days * 10).
// that's obviously the best practice to kill a cookie via php
// @see http://stackoverflow.com/a/686166/1114320
//setcookie('rememberme', false, time() - (3600 * 3650), '/', COOKIE_DOMAIN);
Session::init();
// delete the session
Session::destroy();
}
}
內db.class.php
public function select($table, $where="", $bind="", $fields="*") {
$sql = "SELECT " . $fields . " FROM " . $table;
if(!empty($where))
$sql .= " WHERE " . $where;
$sql .= ";";
return $this->run($sql, $bind);
}
選擇功能我認爲這也許是參考被$ this-> select()方法,但我在學。
如果您發佈有關特定錯誤的信息,您必須**包含完整的錯誤消息(包含行號),並且至少包含該行及其之前的行的代碼。 –
Apologies :: addded – jamper
這個錯誤告訴我的是類UserController沒有一個名爲select()的方法。那是Laravel嗎? –