Last active
November 9, 2015 15:11
-
-
Save dei-biz/e4e4361507c4286d4d09 to your computer and use it in GitHub Desktop.
Insert básico PHP postgresql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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); | |
| } | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
php testPGSQL.php