2

次のメッセージが返されます

致命的なエラー: 次の実行時に、非オブジェクトでメンバー関数 fetch() を呼び出します。散発的なようですが、何か考えはありますか?

    $cc_transaction_conn = new PDO('mysql:host='.$server.';dbname='.$db2use, $dbuser, $dbpass);
    $cc_transaction_query = $cc_transaction_conn->query("CALLgenInsCCTransactionLog('".$vmcnum."',
                                                                                     ".$_SESSION[val].",
                                                                                    'Enrollment',
                                                                                    'Processor',
                                                                                    'Merchant',
                                                                                    'Auth',
                                                                                    '".$card_expiration_month."',
                                                                                    '".$card_expiration_year."',
                                                                                    ".$_SESSION[enrollment_fee].",
                                                                                    '".strtoupper($_SESSION[forename])."',
                                                                                    '".strtoupper($_SESSION[surname])."',
                                                                                    '".strtoupper($_SESSION[house_number])."',
                                                                                    '".strtoupper($_SESSION[street])."',
                                                                                    '".strtoupper($_SESSION[flat_number])."',
                                                                                    '".strtoupper($_SESSION[town])."',
                                                                                    '".strtoupper($billing_post_code)."',
                                                                                    '".$ip_address."',
                                                                                    @cc_insert_id)");
        $cc_transaction_result = $cc_transaction_query->fetch();
        $cc_insert_id = $cc_transaction_result['cc_insert_id'];
        $_SESSION[cc_insert_id] = $cc_insert_id;
        $cc_transaction_conn = NULL;

ストアド プロシージャは次のとおりです。

    CREATE DEFINER=`reliantuksite`@`%` PROCEDURE `genInsCCTransactionLog`(
                        vmc VARCHAR(16),
                        application_id INT UNSIGNED,
                        reas_description VARCHAR(50),
                        in_processor_name VARCHAR(50),
                        merc_name VARCHAR(50),
                        trans_type_description VARCHAR(50),
                        card_expiration_month VARCHAR(2),
                        card_expiration_year VARCHAR(4),
                        amount DECIMAL(6,2),
                        forename VARCHAR(50),
                        surname VARCHAR(50),
                        house_number VARCHAR(255),
                        street VARCHAR(255),
                        flat_number VARCHAR(75),
                        town VARCHAR(50),
                        postal_code VARCHAR(10),
                        ip_address VARCHAR(32),
                        OUT cc_insert_id INT)
    BEGIN

    DECLARE proc_id TINYINT;
    DECLARE pay_reason_id TINYINT;
    DECLARE merc_account_id INT;
    DECLARE trans_type_id TINYINT;
    SELECT processor_id INTO proc_id FROM cc_processor WHERE processor_name = in_processor_name;
    SELECT payment_reason_id INTO pay_reason_id FROM payment_reason WHERE reason_description = reas_description;
    SELECT merchant_account_id INTO merc_account_id FROM cc_merchant_account WHERE merchant_name = merc_name;
    SELECT transaction_type_id INTO trans_type_id FROM transaction_type WHERE transaction_type_description = trans_type_description;
    INSERT INTO
        cc_transaction_log 
            (transaction_sent_date,
            vmc_number,
            application_id,
            processor_id,
            payment_reason_id,
            merchant_account_id,
            transaction_type_id,
            card_expiration_month,
            card_expiration_year,
            amount,
            billing_forename,
            billing_surname,
            billing_house_number,
            billing_street,
            billing_flat_number,
            billing_town,
            billing_postal_code,
            host_ip)
    VALUES
        (NOW(),
        vmc,
        application_id,
        proc_id,
        pay_reason_id,
        merc_account_id,
        trans_type_id,
        card_expiration_month,
        card_expiration_year,
        amount,
        forename,
        surname,
        house_number,
        street,
        flat_number,
        town,
        postal_code,
        ip_address);
    SELECT LAST_INSERT_ID() INTO cc_insert_id;
    SELECT cc_insert_id;
END;;
4

1 に答える 1

4

PDO::query()、マニュアルに書かれているように、PDOStatmentオブジェクトを返すFALSEか、クエリが失敗した場合。オブジェクト以外でメソッドを呼び出そうとするとFALSE、もちろん、取得しているエラーメッセージの生成に失敗します。

したがって、query()結果が false でないかどうかを確認してから、それを呼び出しますfetch()

于 2012-05-04T20:31:36.890 に答える