2016-05-05 5 views
0

PHPをループで使用して100を超える行をpostgresqlデータベースに挿入しようとしています。私は何の誤りもありません。php throughtを使用してpostgresqlに100行以上挿入していない

約50から60レコードを追加しようとすると、データが挿入されています。レコードが100周年以上になると挿入されません。

以下は試したコードです。この問題を解決してください。

ありがとうございます。

<?php 
    $userid = $_SESSION['user_id']; 
     $array =''; 
     $resultAgain =''; 
    if (isset($_POST['save'])) { 

     // $sponsorship_id = $_POST['sponsorid']; 
     $resultAgain=array(); 
     $resultAgain = $_SESSION['arr_rows']; 

    for ($i = 0; $i <count($resultAgain); ++$i) { 

    $recieptid = $resultAgain[$i]['recieptid']; 
    $childid = $resultAgain[$i]['childid']; 
    $openingbalance_fee = $resultAgain[$i]['openingbalance_fee']; 
    $openingbalance_familyhelp = $resultAgain[$i]['openingbalance_familyhelp']; 
    $mayreciept = $resultAgain[$i]['mayreciept']; 
    $december_reciept = $_POST['decreciept'.$resultAgain[$i]['presentclass']]; 
    $adminfees = $_POST['adminfees'.$resultAgain[$i]['presentclass']]; 
    $schoolfee = $_POST['schoolfee'.$resultAgain[$i]['presentclass']]; 
    $familyhelp = $resultAgain[$i]['family_help']; 
    $year = $_POST['yearName']; 
    $submit = $_POST['save']; 
     // call insert function 
      $sql1="SELECT fn_reciept_insert($childid, 
             '$openingbalance_fee', 
             '$openingbalance_familyhelp', 
             '$mayreciept', 
             '$december_reciept', 
             '$adminfees', 
             '$familyhelp', 
             '$schoolfee', 
             '$year', 
             $userid, 
             localtimestamp, 
             $userid, 
             localtimestamp)"; 
      $result1 = pg_query($dbconn,$sql1); 
     if (!$result1) { 
    echo '<script>alertMX("Data Not Updated")</script>'; 
    } 
else 
    { 
    echo '<script>alertMX("Data inserted Successfully")</script>'; 
    } } 
    } 
} 
?> 
+0

いくつかのコードを表示します。 PostgreSQLの使い方PDOまたはpg_ *? – Michas

+0

私はpostgreSQLのpg_ *を使用しています。 –

+0

詳細は、 'pg_last_error()'を参照してください。http://php.net/manual/en/function.pg-last-error.php – Michas

答えて

0

まず、あなたがあなたのスクリプトの終わりにそのDB接続を閉じていることを確認してください。あなたが問題を抱えておく場合はその後、あなたのmax_connectionshttps://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server#max_connections

ALTER SYSTEM SET max_connections TO 300;

とPostgreSQLサーバを再起動を大きくしてみてください。

また、問題のデータ量がINSERTになっていない可能性があります。エスケープされていないデータを使用してクエリを作成しています。それはどういう意味ですか?その大きなクエリ文字列に入れた変数の1つが'文字の場合、クエリ文字列が壊れて大きなセキュリティ上の問題となります(SQLインジェクションを参照)。データの量が多いほど、チャンスは大きくなります'が表示されます。あなたはする必要がありますescape your data

関連する問題