PHP-MySQL is migrating to PostgreSQL. What do i need to know?

I developed most of my applications in PHP-MySQL because it was quick and easy. Now, with more complex applications, and I wonder if MySQL is a good choice. I will be creating my latest application with PostgreSQL. What do i need to know? What did I miss when using MySQL?

+8
php mysql postgresql
source share
2 answers

This wiki page is a good start:
http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#MySQL

Edit: answer the second part (things you were missing):

  • generate_series ()
  • pending restrictions
  • check restrictions
  • recursive queries
  • table functions
  • common table expressions
  • window functions
  • function based index
  • partial indexes
  • full-text search in transactional tables
  • GIS functions in transactional tables
  • MINUS or INTERSECT statement

Edit2: anything that might seem problematic

  • PostgreSQL is much more stringent in terms of data type mapping (where character_column = 1 will throw an error)
  • no cross-database queries, if you need something similar, matching MySQL databases with PostgreSQL schemas is probably easier
  • There are no variables in regular SQL operations (set @nr = 1; select @nr + 1 ...)
+5
source share

Read the thin guide , chapters 2 through 9 are the most important to get you started.

Make sure that you are doing the correct error handling in PHP and carefully reading all the error messages: in most cases, it tells you exactly what went wrong and how to fix it. Appendix A contains all the error messages and codes you need. PostgreSQL does not accept invalid input or queries, it fixes or you get an error to start debugging. And this is good, fewer errors and less time you spend on scripts.

pg_query_params () and pg_fetch_all () are some great functions in PHP for interacting with PostgreSQL, check the PHP manual .

+1
source share

All Articles