Is it possible to dump a database using doctrine 2? I have read that symfony has a library which extends doctrine to do it but How could I use it in my zendframework project with Bisna Doctrine 2 Integration?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
This is an old thread but I was just doing something similar in Symfony and decided to develop an actual command for it. That's more of a Symfony way of doing it and gives you more control on the output as well as allowing you access to the parameters, so you don't have to parse Yaml using bash script :)
and AbstractCommand is just a class that extends symfony's ContainerAwareCommand:
I created a small script that read the parameters from
app/config/parameters.yml
and output all the data from a MySQL database to a file (with current datetime used as name).Save this in the root of your Symfony project (e.g.
mysqldump.sh
):Result when running the script:
For Symfony2:
Type
in the command line
Doctrine has no database-dump feature. I agree it would be nice, but it's also not the ORM's goal.
You could dump the database using
Here's an article explaining those solutions.
Depend on your database. if you use mysql, create a php command to utilise
mysqldump
like running this
mysqldump -u YourUser -p YourDatabaseName > wantedsqlfile.sql
For a more generic doctrine way: