From 7e184016bbcc6f3429d81798a22489ba0d086c98 Mon Sep 17 00:00:00 2001 From: Stefan Wrobel Date: Thu, 31 Oct 2013 16:56:57 -0700 Subject: [PATCH] Quote Everything! --- README.md | 6 ++++-- pg2mysql.inc.php | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4673b53..e5c2838 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,15 @@ ## Command-Line usage (recommended) -1. `PGPASSWORD=yourpass pg_dump -h localhost --column-inserts --no-acl --no-owner --format p --data-only dbname -f pgfile.sql` +1. `PGPASSWORD=yourpass pg_dump -h localhost --column-inserts --quote-all-identifiers \` + `--no-acl --no-owner --format p --data-only dbname -f pgfile.sql` + Additional documentation for `pg_dump` [here](http://www.postgresql.org/docs/9.3/static/app-pgdump.html) 1. `php pg2mysql_cli.php pgfile.sql mysqlfile.sql [engine]` * `pgfile.sql` will not be modified * `mysqlfile.sql` will be overwritten if already exists - * engine is optional, defaults if not specified is InnoDB + * engine is optional, default if not specified is InnoDB 1. `mysql dbname < mysqlfile.sql` diff --git a/pg2mysql.inc.php b/pg2mysql.inc.php index f93fb12..0176913 100644 --- a/pg2mysql.inc.php +++ b/pg2mysql.inc.php @@ -342,9 +342,8 @@ function pg2mysql(&$input, $header=true) if(strstr($line," PRIMARY KEY ") && substr($line,-3,-1)==");") { //looks like we have a single line PRIMARY KEY definition, lets go ahead and add it $output.=$pkey; - //the postgres and mysql syntax for this is (at least, in the example im looking at) - //identical, so we can just add it as is. - $output.=$line; + //MySQL and Postgres syntax are similar here, minus quoting differences + $output.=str_replace("\"","`",$line); } }