doushang4274 2014-02-08 05:44
浏览 42
已采纳

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

I'm trying to validate a User using Ardent's validate() method, but I always receive the HY093 error with the following extra information

(SQL: select count(*) as aggregate from:userswhereemail= my.email@gmail.com)

I used Sentry2 for my 'users' table database migration.

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:

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. Can anyone help me shed some light upon this situation?

  • 写回答

1条回答 默认 最新

  • douqianbiao4216 2014-02-13 03:51
    关注

    The issue was this line

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

    Should have been

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

    According to The Laravel Docs

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据