I can use this to execute SQL at the CLI
php app/console doctrine:query:sql "SELECT * FROM table"
But how can I use the same command to exec SQL from a file? E.g.
php app/console doctrine:query:sql filename.sql
I have tried >
and <
in various ways and cat
but nothing even comes close to doing what I want.
I realised I can use straight mysql
to do this, but I wish to do it via doctrine.
use the MySQL command line client: mysql -h hostname -u user database < path/to/test. sql. Install the MySQL GUI tools and open your SQL file, then execute it.
php app/console doctrine:query:sql "$(< filename.sql)"
With a current Symfony/Doctrine version you can easily run:
php bin/console doctrine:database:import [files]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With