-1

フォロー機能が機能しない

public function matchingService() {

    $stmt = mysqli_prepare($this->connection, "
    INSERT INTO reusematching.matchedtable(user_idUser, productDetail_idProduct,Status,applyData)
        SELECT  waitinglist_user.user_idUser, 
                waitinglist_product.ProductDetail_idProduct, 
                productstatus,          
                waitinglist_user.waitinglistUser_applydata
                FROM reusematching.waitinglist_user, 
                reusematching.waitinglist_product, 
                productinformation.productdetail, 
                productinformation.productstatus
                where (waitinglistProduct_status = 1 
                and waitinglistUser_status = 1 
                and productCategroy_productCategroyID = waitinglistUser_applyProductType
                and ProductDetail_idProduct = idProduct
                and idStatus = waitinglistProduct_status);

    SET SQL_SAFE_UPDATES=0; 

    DELETE FROM reusematching.waitinglist_user
    WHERE Exists
                    (SELECT matchedtable.idMatchedTable
                        FROM  reusematching.matchedtable 
                        where  matchedtable.user_iduser= waitinglist_user.user_idUser);

    DELETE FROM reusematching.waitinglist_product
    WHERE Exists
                    (SELECT matchedtable.idMatchedTable
                        FROM  reusematching.matchedtable 
                        where  matchedtable.ProductDetail_idProduct
                                = waitinglist_product.ProductDetail_idProduct);

    SET SQL_SAFE_UPDATES=1;

    "); 

    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();


    mysqli_stmt_free_result($stmt);
    mysqli_close($this->connection);


    return null;
}

示されているフレックス

サーバーエラーMySQLエラー-1064:SQL構文にエラーがあります。MySQLサーバーのバージョンに対応するマニュアルで、「DELETE FROMreusematching.waitinglist_user WHERE Exists(SELECT matche」の18行目)の近くで使用する正しい構文を確認してください。

なぜこのエラーが発生するのですか?とそれをデバッグする方法。

4

1 に答える 1

0

PHPのmysqlドライバーでは、1回のquery()呼び出しで複数のクエリを発行することはできません。これは、古いmysql関数と新しいmysqli関数の両方に当てはまります。これは、SQLインジェクション攻撃のいくつかの形式を防ぐためのセキュリティ対策です。

恐ろしいほど大きなクエリステートメントを複数の(小さい)個別のクエリに分割する必要があります。

a) INSERT ... SELECT
b) SET ...
c) DELETE ..
d) etc...
于 2012-09-10T17:00:31.067 に答える