'Zend_Db_Statement_Exception' with the message 'Invalid bind variable name': 1 '

Good afternoon,

Background Information:

The client hosting server is being upgraded from PHP 5.2 to PHP 5.3. The client application breaks when testing in PHP 5.3. In particular, insert and update methods are those that violate the application. The application is encoded in Zend Framework v1.7.2.

We tried just updating the core of the Zend Framework, however, it seems that previous developers made changes to the kernel, which causes the application to crash completely when the infrastructure was updated.

Problem

The best solution was to add a class called AppModel that extends Zend_Db_Table_Abstract and then simply overwrites the insert and update methods. All models in this application extend the AppModel class. This works fine until the flag data or radio button data is written to the database.

The application now throws the following error:

Fatal error: throw exception "Zend_Db_Statement_Exception" with message 'Invalid bind variable name': 1 '' in ....

NB. Full error message below

. , , Mysqli Pdo_Mysql. , , . Pdo, , Mysqli.

, !

. , , .

AppModel:

class AppModel extends Zend_Db_Table_Abstract{
                //PHP 5.3 fix   
                public function insert(array $data) {

                    //array to carry data for holding data
                    $ins_data = array();

                    foreach($data as $table => $value){
                        $ins_data['tables'][] = $table;
                        $ins_data['values'][] = mysql_escape_string($value);
                    }

                    $db = Zend_Registry::get('db');                    

                    $ins_query = ' INSERT INTO '.  $this->_name.' ('.implode($ins_data['tables'], ', ').')
                                   VALUES ("'.implode($ins_data['values'], '", "').'")'; 
                    $ins_action = new Zend_Db_Statement_Mysqli($db, $ins_query);
                    $ins_action->execute();
                    return $db->lastInsertId();
                }        
}

:

Fatal error: 
    Uncaught exception 'Zend_Db_Statement_Exception' 
    with message 'Invalid bind-variable name ':1'' 
    in C:\wamp\www\schoolnet\public_html\Zend\Db\Statement.php:143 
Stack trace: 
#0 C:\wamp\www\schoolnet\public_html\Zend\Db\Statement.php(108): Zend_Db_Statement->_parseParameters(' UPDATE user_te...') 
#1 C:\wamp\www\schoolnet\application\AppModel.php(43): Zend_Db_Statement->__construct(Object(Zend_Db_Adapter_Mysqli), ' UPDATE user_te...') 
#2 C:\wamp\www\schoolnet\application\modules\user\helpers\UserHelper.php(530): AppModel->update(Array, 'user_id = 6') 
#3 C:\wamp\www\schoolnet\application\modules\user\controllers\UserController.php(533): user_helpers_UserHelper->teacherUpdate(Array, 6) 
#4 C:\wamp\www\schoolnet\application\modules\user\controllers\UserController.php(300): UserController->teacherUpdateDetails(Array, 6) 
#5 C:\wamp\www\schoolnet\public_html\Zend\Controller\Action.php(503): UserController->detailseditAction() 
#6 C:\wamp\www\schoolnet\public_html\Zend\Controller\Dispatcher\Standard.php(285): Zend_Control in C:\wamp\www\schoolnet\public_html\Zend\Db\Statement.php on line 143
+3

Source: https://habr.com/ru/post/1569030/


All Articles