Skip to content

Instantly share code, notes, and snippets.

@dei-biz
Last active November 9, 2015 15:11
Show Gist options
  • Select an option

  • Save dei-biz/e4e4361507c4286d4d09 to your computer and use it in GitHub Desktop.

Select an option

Save dei-biz/e4e4361507c4286d4d09 to your computer and use it in GitHub Desktop.
Insert básico PHP postgresql
<?php
$dbconn = pg_connect("host= dbname=OTIENDA user= password=")
or die('Could not connect: ' . pg_last_error());
$query = file_get_contents('data.txt');
$time_start = microtime_float();
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
$time_end = microtime_float();
$time = round($time_end - $time_start, 3);
echo "PHP ha llevado $time segundos";
print "\n";
pg_free_result($result);
pg_close($dbconn);
function microtime_float(){
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
?>
@dei-biz
Copy link
Author

dei-biz commented Nov 9, 2015

php testPGSQL.php

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