Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Execute SQL dump

Hello. I would like to make it easier to deploy my code between servers, so i need to import a dump (around 1k lines of SQL) every time i try to install it.

I would like to automatize this by creating an CLI task that installs and update my code automatically but couldn't find a function in \Phalcon\Db\Adapter\Pdo\Postgresql to execute a full dump. Is there any way to do this with this object ? ( i mean, without using psql or devtools ) ?



6.1k

To be more explicit, my .sql has several CREATE SCHEMA, CREATE TABLE, ALTER TABLE and CREATE INDEX queries. With the \Phalcon\Db\Adapter\Pdo\Postgresql i can only execute one query at time...



82.8k
Accepted
answer


6.1k

Ok. So i think i figured out an workaround: I created a function that uses the PHP file functions to read the SQL file and explode it into statements (searching by the ; character. Now i can do an foreach to execute it :p (probably will have performance issues but that is not a problem)