I am executing a php script which insert more then 500 rows in multiple relational tables in a loop using pdo->exec()
Code Example:
pdo->beginTransaction();
while (until condition) {
$sqlqry="Insert Into Table 1";
pdo->exec($sqlqry);
$sqlqry="Insert Into Table 2";
pdo->exec($sqlqry);
$sqlqry="Insert Into Table 3";
pdo->exec($sqlqry);
}
pdo->commitTransaction();
I just wanted to know is this a good practice or i should do perform all insert quires at a same time or what is the best way to perform such multiple insert quires.
I am focusing on :
1) Best way to execute bulk insert multiple queries.
2) Friendly for db server.