Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
442 views
in Technique[技术] by (71.8m points)

database - How to persist multiple entities as fast as i can Symfony 5

i'm trying to add xlsx data to my data base as entities i wrote this script

$batchCount = 10000;
$i = 0;
foreach($rows as $row) {
                if (is_numeric($row[0])){
                    $i++;
                    $cart = new Carte();
                    //doing something
                    $this->em->persist($cart);
                    if (($i % $batchCount) == 0) {
                        $this->em->flush();
                        $this->em->clear();
                   }
                }
            }

But for a adding 50,000 line in database its taking to long I'd love if some one have fast method to add large data to database using Symfony

question from:https://stackoverflow.com/questions/65919964/how-to-persist-multiple-entities-as-fast-as-i-can-symfony-5

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...