首页 > 解决方案 > 如何正确地将我的变量绑定到我的令牌?

问题描述

我不知道是什么导致了这个错误,我已经筋疲力尽了。我不知道如何解决这个问题。

警告:PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: 绑定变量的数量与 C:\wamp64\www\myproject-dev\public\viajes\orden_mantenimiento\controller.php 中的令牌数量不匹配第77

当我尝试执行我的 create 方法时会发生这种情况,因此这是整个方法:

if ($type == 'create') {
        $Records = $request->models;
        foreach ($Records as $rec) {
            if (isset($request->pky)) {
                $fky = $request->fky;
                $rec->$fky = $request->pky;
            }

            $aError = Validate($rec);

            $statement = $conn->prepare('INSERT INTO order (id, idVehiculo, idTipo, fecha, kilometraje, horaIn, horaSal, proyecto, jefeProy, aprobadoPor, descripcion) 
                                            VALUES (:id, :idVehiculo, idTipo, :fecha, :kilometraje, :horaIn, :horaSal, :proyecto, :jefeProy, :aprobadoPor, descripcion)');

                $statement->bindValue(':id', $rec->id);
                $statement->bindValue(':idVehiculo', $rec->idVehiculo);
                $statement->bindValue(':idTipo', $rec->idTipo);
                $statement->bindValue(':fecha', $rec->fecha);
                $statement->bindValue(':kilometraje', $rec->kilometraje);
                $statement->bindvalue(':horaIn', $rec->horaIn);
                $statement->bindvalue(':horaSal', $rec->horaSal);
                $statement->bindValue(':proyecto', $rec->proyecto);
                $statement->bindValue(':jefeProy', $rec->jefeProy);
                $statement->bindValue(':aprobadoPor', $rec->aprobadoPor);
                $statement->bindValue(':descripcion', $rec->descripcion);

                if (!$statement->execute()) {  // **========================== THIS IS LINE 77 ===================**
                    $aErrInfo = $statement->errorInfo();
                    $aError = array();
                    $aError[] = array('success' => false);
                    $aError[] = array('msg' => $aErrInfo[1]);
                    $aError[] = array('error' => $aErrInfo[2]);
                    $respuesta["errors"] = $aError;
                    echo "statement error".$respuesta;
                } else {
                    $rec->id = $conn->lastInsertId();
                    $respuesta["data"] = $rec;
                    echo "Data bound.";
                }
            } else {
                $respuesta["errors"] = $aError;
                echo "ERROR";
            }
        }
    }


提前非常感谢。

标签: pdokendo-ui

解决方案


推荐阅读