<commit_before><?php

// YAY INTERNET! (https://github.com/kch/heroku-php-pg/blob/master/index.php)
function pg_connection_string_from_database_url() {
  extract(parse_url($_ENV["DATABASE_URL"]));
  return "user=$user password=$pass host=$host dbname=" . substr($path, 1); # <- you may want to add sslmode=require there too
}

$sql_connection = pg_connect(pg_connection_string_from_database_url());
if (pg_connection_status($sql_connection) != PGSQL_CONNECTION_OK)
{
	error_log("Error connecting to database.");
}

function sqlQuery($q, $params=null)
{		
	global $sql_connection;
	
	if ($params)
	{
		$q_result = pg_query_params($sql_connection, $q, $params);
	}
	else
	{
		$q_result = pg_query($sql_connection, $q);
	}
	
	if (!$q_result)
	{
		return null;
	}
	
	$ret = pg_fetch_all($q_result);
	
	return $ret;
}

?><commit_msg>Fixed bug with 'sqlQuery' function<commit_after><?php

// YAY INTERNET! (https://github.com/kch/heroku-php-pg/blob/master/index.php)
function pg_connection_string_from_database_url() {
  extract(parse_url($_ENV["DATABASE_URL"]));
  return "user=$user password=$<PASSWORD> host=$host dbname=" . substr($path, 1); # <- you may want to add sslmode=require there too
}

$sql_connection = pg_connect(pg_connection_string_from_database_url());
if (pg_connection_status($sql_connection) != PGSQL_CONNECTION_OK)
{
	error_log("Error connecting to database.");
}

function sqlQuery($q, $params=null)
{		
	global $sql_connection;
	
	if ($params)
	{
		$q_result = pg_query_params($sql_connection, $q, $params);
	}
	else
	{
		$q_result = pg_query($sql_connection, $q);
	}
	
	
	$ret = pg_fetch_all($q_result);
	if (!$ret) // I want to be able to iterate over the result in index.php
	{
		$ret = array( );
	}

	return $ret;
}

?>
{'fraction_non_alphanumeric': 0.15442020665901263, 'fraction_numerical': 0.001148105625717566, 'mean_word_length': 5.26978417266187, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3780401', 'n_tokens_mistral': 665, 'n_tokens_neox': 641, 'n_words': 124}