简体   繁体   中英

Message: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters

I have come across this Error I've not seen before:

Message: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters 

Referring to the following code (have simplified the function for ease of reading):

if ($frm->isValid($this->_getAllParams()) || !count($frm->getMessages())) //error points to this line of an array
                {
                    //set session with id of user
                    $session = new Zend_Session_Namespace('rg');
                    $session->userid = $this->getRequest()->getPost('id');
                    //update the user
                    $mdl->createClient($this->_getAllParams());
                    //add to log - do in model
                    $this->_redirect('/.../...');
                }

6 C:\\xampp\\htdocs\\portal-gep-2\\library\\Null\\Validate\\Db\\NoRecordExists.php(7): Zend_Validate_Db_NoRecordExists->isValid('7505020152089')

class Null_Validate_Db_NoRecordExists extends Zend_Validate_Db_NoRecordExists
{
    public function isValid($value)
    {
       $response = parent::isValid($value);//this line
       if(!$response){
           $this->_messages =
                array(self::ERROR_RECORD_FOUND=> "Please correct this error before continuing <a href='/data-control/idnum/id/$value'>Correct Issue</a>");
       }
       return $response;
    }
}

The form in question has a constructor of the form:

public function __construct($formState = 'createlocal', $currentTask = null)

based on whether the form is updating an existing record or a new record it will make use of a custom validator: Null_Validate_Db_NoRecordExists .

In the specific case you talk of the form is using a Db_NoRecordExists on an existing record and hence we whould like to exclude a specific record (the current one) using one of the constructor parameters in this case: $currentTask .

$currenctTask may be an array and the validator may make use of an array variable while ensuring the Record does not exist (in the where clause). However the variable is not parsed when initially constucting the form.

Hence check that $currentTask contains what it needs to contain. The error is of your own making.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM