Instantly share code, notes, and snippets.

@sabadow /ExampleWithDB.php Secret
Last active Aug 29, 2015

What would you like to do?
Example for the #DevBurgos talk about Heroku
# function that reads DATABASE_URL env var and returns a connection
function pg_connection_string_from_database_url() {
return "user=$user password=$pass host=$host dbname=" . substr($path, 1);
print "<h1>hello #DevBurgos</h1>";
# Establish the connection.
$pg_conn = pg_connect(pg_connection_string_from_database_url());
# silly query
$result = pg_query($pg_conn, "SELECT now()");
#print the result if has any
if (pg_num_rows($result)) {
print "\nObtained from DB:";
$row = pg_fetch_row($result);
print("- $row[0]");
web: vendor/bin/heroku-php-nginx

This comment has been minimized.

Copy link

sabadow commented May 7, 2014

Useful command heroku addons:add heroku-postgresql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment