We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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 ) ?



11.2k

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...



98.9k
Accepted
answer


11.2k

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)