The supplied parameters to Zend_Auth_Adapter_DbTable failed to produce a valid sql statement

前端 未结 7 2236
终归单人心
终归单人心 2021-01-25 01:53

I have the following exception Caught exception: The supplied parameters to Zend_Auth_Adapter_DbTable failed to produce a valid sql statement, please check table and colum

7条回答
  •  一整个雨季
    2021-01-25 02:51

    It depends on MySQL version as described above. Following MySQL Documentations for version 5.5:

    "If an application stores values from a function such as MD5() or SHA1() that returns a string of hex digits, more efficient storage and comparisons can be obtained by converting the hex representation to binary using UNHEX() and storing the result in a BINARY(N) column. Each pair of hex digits requires one byte in binary form, so the value of N depends on the length of the hex string. N is 16 for an MD5() value and 20 for a SHA1() value."

    So, instead of downgrading MySQL version, you may do as follows:

    • change type of 'password' column from varchar(32) to binary(16)
    • add 'UNHEX()' MySQL function to your MySQL query in ZF code, for example:
    $adapter = new Zend_Auth_Adapter_DbTable(
        $db,
        'user',
        'login',
        'password',
        'UNHEX(MD5(CONCAT(?, passwordSalt)))'
    );
    

    It works well in my case.

    Edit -- If your password salt is also stored in a binary column (e.g. if it too was a hex string generated through the SHA1 function) then the last parameter of the Zend_Auth_Adapter_DbTable should be: 'UNHEX(SHA1(CONCAT(?, LOWER(HEX(salt)))))' So, we are converting the salt back to a lowercase hex string before concatenating with the password. HEX() returns your salt in uppercase so you can just omit the LOWER() call if your salt was originally uppercase before you stored it using UNHEX().

提交回复
热议问题