Comments (12)
Please try these suggestions: #57 (comment)
from liiptestfixturesbundle.
Hello, I don't understand what I must try because my fixtures are in the src/Datafixtures repository.
from liiptestfixturesbundle.
In the fixture, I changed the Doctrine\Common\DataFixtures\FixtureInterface implementation to Doctrine\Common\DataFixtures\AbstractFixture implementation. I don't have anymore the previously error, but the data aren't saved in the database.
from liiptestfixturesbundle.
You need to persist data: https://symfony.com/doc/3.0/bundles/DoctrineFixturesBundle/index.html#writing-fixtures
Add this for every entity:
$manager->persist($user);
$manager->flush();
from liiptestfixturesbundle.
Of course! Really sorry for this mistake on my part and thank you very much for your help.
from liiptestfixturesbundle.
Add this for every entity:
$manager->persist($user);
$manager->flush();
are you saying that we need to flush
inside the loop ?
flush
is designed to be called only once at the end, or isn't that what you meant ?
edit : I also saw an article where someone was flushing in the loop, so I'm really curious if there is something i don't know about.
I don't wanna do it unless it's really necessary since that sounds like a waste of resource.
from liiptestfixturesbundle.
@vulkanosaure you can call flush()
only once, it should work.
If you add tens or hundreds of entities, check the doc about Batch Processing: https://www.doctrine-project.org/projects/doctrine-orm/en/2.16/reference/batch-processing.html
See also this answer on Stack Overflow: https://stackoverflow.com/a/21335487/2257664 (spoiler: it's mine 😁)
from liiptestfixturesbundle.
thanks but why isn't using one single flush
for a hundred of entities recommended ?
is it slower than the batch process you describe ? (eg: 10 flush
that each handle 10 persist
)
from liiptestfixturesbundle.
Adding hundreds of records then:
- using only
flush
at the end may use a lot of RAM (hydrated entities can be pretty heavy). If I remember correctly Doctrine had performance issues when dealing with thousand of entities and the finalflush
was slow. It was about 10 years ago though so it may be better now - using
flush
on every iteration of the loop may be slower since it will perform many requests
Between these 2 cases, batch processing is a trade-off and it can help to not overwhelm Doctrine. It depends on the amount of data to be stored, so the first step is to test and see if you encounter performance issues, if that's the case then you can try different sizes for the batch. If you have no slowness when adding entities, keep one flush
and move along.
from liiptestfixturesbundle.
ok, thanks for the insights !
from liiptestfixturesbundle.
from liiptestfixturesbundle.
@vulkanosaure Let's discuss this there:
from liiptestfixturesbundle.
Related Issues (20)
- Drop support of PHP 7.2 and 7.3? HOT 1
- [Bug]: keep_database_and_schema config is ignored it is always false with SQL Server HOT 2
- facing issue in new pimcore version 10.6 HOT 5
- [Feature Request]: Add LoadFixtureGroup method HOT 2
- Deprecated DBAL APIs still in use HOT 1
- Question: cached database with GitLab CI pipeline HOT 2
- Load fixture without a file path HOT 7
- [Feature Request]: Support Symfony 7 HOT 1
- [Bug]: $referenceRepository->getReferences() is broken HOT 1
- [Bug]: mysqldump: unknown variable 'column-statistics=0' error HOT 7
- Performance with LiipTestFixturesBundle v2.6.0 HOT 7
- SqlitePlatform::getName() is deprecated HOT 4
- [Bug]: Impossible to set "keep_database_and_schema" HOT 4
- [Bug]: 2.7.2 - Doctrine MongoDB Manager can not be used anymore HOT 2
- [Feature Request]: Upgrading doctrine/dbal Connection handling HOT 5
- [Feature Request]: Support "doctrine/dbal" 4 HOT 1
- [Feature Request]: Prepare release 3.x HOT 1
- [Bug]: Undeclared dependency on doctrine/dbal ^3.1.0 | ^4.0.1 HOT 3
- [Feature Request]: Support doctrine/dbal 4
- contributing: MongoDb extension on Mac M1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liiptestfixturesbundle.