简体   繁体   English

Laravel / Ardent:SQLSTATE [HY093]:无效的参数编号:混合的命名和位置参数

[英]Laravel/Ardent: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters

I'm trying to validate a User using Ardent's validate() method, but I always receive the HY093 error with the following extra information 我正在尝试使用Ardent的validate()方法验证用户,但是我总是收到带有以下附加信息的HY093错误

(SQL: select count(*) as aggregate from :users where email = my.email@gmail.com) (SQL: select count(*) as aggregate from用户where (SQL: select count(*) as aggregate from where email = my.email@gmail.com)

I used Sentry2 for my 'users' table database migration. 我使用Sentry2进行“用户”表数据库迁移。

I have my User model set up like this: 我的用户模型设置如下:

/**
* Validation Rules for ARDENT here
*/    
public static $rules = [
    'first_name'            => 'required',
    'last_name'             => 'required',
    'email'                 => 'required|email|unique::users',
    'password'              => 'required|between:8,32|confirmed',
    'password_confirmation' => 'required|between:8,32',
];

/**
 * The attributes that can be added to a new User using $user->fill()
 *
 * @var array
 */
protected $fillable = [
    'first_name', 
    'last_name', 
    'email', 
    'password', 
    'password_confirmation'
];

/**
 * Automatically removes _confirmation attributes
 *
 * @var boolean
 */
public $autoPurgeRedundantAttributes = true;

From a form, I have POST data that includes ['email', 'first_name', 'last_name', 'password', 'password_confirmation] with their respective values that go to the following function in my UserController: 从表单中,我具有包含['email','first_name','last_name','password','password_confirmation]的POST数据,它们的值分别进入UserController中的以下函数:

public function signup() {
    // Create a new User object
    $user = new User();

    // Populate attributes with information described in User->fillable
    $user->fill( Input::all() );

    // Check if info is valid using Ardent's validate() method
    if ( $user->validate() ) {
    ....
    ....
    ....

My code always fails on the if ( $user->validate() ) line. 我的代码总是在if ( $user->validate() )行上失败。 Can anyone help me shed some light upon this situation? 谁能帮助我阐明这种情况?

The issue was this line 问题是这条线

'email' => 'required|email|unique::users'

Should have been 本来应该

'email' => 'required|email|unique:users'

According to The Laravel Docs 根据Laravel文件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQLSTATE [HY093]:参数号无效:混合命名和位置参数 - SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters PHP PDO:SQLSTATE[HY093]:无效的参数号:混合命名和位置参数 - PHP PDO: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters Yii2,ActiveQuery,PostgreSQL:SQLSTATE [HY093]:无效的参数编号:混合的命名和位置参数 - Yii2, ActiveQuery, Postgresql: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters 致命错误:未捕获的PDOException:SQLSTATE [HY093]:无效的参数编号:混合的命名和位置参数位于 - Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters in 消息:SQLSTATE[HY093]:无效的参数号:混合命名和位置参数 - Message: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters SQLSTATE [HY093]:无效的参数编号(参数不匹配) - SQLSTATE[HY093]: Invalid parameter number (parameters not match) SQLSTATE [HY093]:无效的参数号:未绑定任何参数 - SQLSTATE[HY093]: Invalid parameter number: no parameters were bound SQLSTATE [HY093]:laravel模型查询中的参数号无效 - SQLSTATE[HY093]: Invalid parameter number on laravel model query SQLSTATE [HY093]:参数号无效:参数未定义 - SQLSTATE[HY093]: Invalid parameter number: parameter was not defined SQLSTATE [HY093]:无效的参数编号:参数未定义# - SQLSTATE[HY093]: Invalid parameter number: parameter was not defined #
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM