Answer the question
In order to leave comments, you need to log in
Why are some INSERTs not added?
while(1) {
$PDO = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$PDO->exec("TRUNCATE TABLE fonbet");
foreach($data as $object) {
$sql = "INSERT INTO fonbet (id, password, куча полей) VALUES (:id, :password, куча значений)";
$query = $PDO->prepare($sql);
$query->execute(array(':id'=>$object->id, ':password'=>$object->password, куда соответствий));
}
}
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2342 root 20 0 172m 34m 13m S 32.6 6.9 7:01.99 php
2248 mysql 20 0 890m 225m 15m S 6.3 45.7 0:54.46 mysqld
Answer the question
In order to leave comments, you need to log in
It would not be bad to process errors
php.net/manual/ru/pdo.errorinfo.php
when doing prepare/execute
And yet - an eternal loop? Maybe pull the crown? The same script execution time should be made eternal, is it set in your php.ini or on the script? At least set the minimum slip, otherwise it’s not ice.
And something tells me that the ideology is violated?
It seems to me that prepare should be moved out of the loop and made into a transaction, no?
You need to add data inside the transaction - it will be faster this way.
Also, I don't think mysql is a good choice in this case.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question