birden fazla veritabanı ile çalışan php ve mysql yardım

0 Cevap php

I need to work on multiple database, and below is my current code. Following code seems to be very very slow and having issues with multiple connection while I view the mysql connection list.

Yani herkes koduyla yanlış ne edeyim ve ben sorunları ve hızlı performans düzeltmek için yardımcı olabilir.


$dbHost="localhost";
$dbUser="user";
$dbPass="pass";
$db_1="database1";
$db_2="database2";

$connect=mysql_connect($dbHost, $dbUser, $dbPass);
if (!$connect)
die("Error Connecting to MYSQL");
mysql_select_db($db_1, $connect)
or die("Error Connecting to Database 1");

$remainingDataCount="25000";

$getData=mysql_query("select * from TABLE where FIELD1='data' && FIELD2>'date' && FIELD3='NO'");
$loop=0;
while ($eachData=mysql_fetch_array($getData)) {
    $loop++;
    $UNIQUE_ID=$eachData['id'];
    $UNIQUE_DATA1=$eachData['FIELD4'];
    $DATA2=$eachData['FIELD5'];

    $responseMessage="some text here";
    $currentTimeStamp=date('Y-m-d H-i-s');

    if ($loop>$remainingDataCount) {
        break;
    } else {

        $insertQuery=mysql_query("insert into ".$db_2.".TABLE values('', '$UNIQUE_DATA1', '$DATA2', '$responseMessage', '$currentTimeStamp')");

        if ($insertQuery==true) {

            $updateQuery=mysql_query("update ".$db_1.".TABLE set FIELD1='YES', FIELD2='$responseMessage', FIELD3='$currentTimeStamp' where FIELD4='$UNIQUE_DATA1'");
            if ($updateQuery==false) {
                mysql_query("delete from ".$db_2.".TABLE where FIELD1='$UNIQUE_DATA1'");
            }

        }
    }

}

0 Cevap