Jump to content

Php Postgresql Database Connection


colap

Recommended Posts

http://www.php.net/manual/en/pgsql.examples-basic.php

 

Is it the prefered/suggested/recommended way to connect with postgresql database with php?

 

Or should i use pdo or something else? http://www.php.net/manual/en/pdo.pgsqllobcreate.php

 

For mysql the pdo is recommeded by php users.

Link to comment
https://forums.phpfreaks.com/topic/270930-php-postgresql-database-connection/
Share on other sites

I don't have much experiance, or any actualy, with PSQL, but I will say that from the link you posted PDO looks like it would be the more secure option, and thus the recomended one. Because PDO uses bindings it adds another layer of security to the query that it sends, because it won't let string injections bind to int values and such. All user input should, of course, sill be safely sanitized outwith this as you shouldn't count on anyone but yourself to make your code safe.

 

Moreover, I personaly would suggest using PDO. It's a powerfull - if somewhat over complicated - class that, once you know it will standardise how you connect to and query databases quite a lot regardless of if it's PSQL, MYSQL or any other (except MS-SQL, unless/untill PDO has been updated to work with the sqlsrv driver extension).

 

That's my take on it anyway, hope it helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.