postgresql
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| postgresql [2011/06/05 13:08] – admin | postgresql [2011/06/05 13:12] (aktuell) – admin | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ====== PostgreSQL ====== | ====== PostgreSQL ====== | ||
| - | [[PHP mit PostgreSQL]] \\ | + | ===== PHP Integration |
| - | ===== PostgreSQL Passwort zurücksetzen | + | |
| - | < | + | [[http:// |
| - | echo "localhost | + | |
| - | su - postgres | + | < |
| - | psql | + | < |
| - | CREATE USER root WITH PASSWORD ' | + | < |
| - | ALTER ROLE root SUPERUSER; | + | |
| - | \q | + | |
| + | |||
| + | <? | ||
| + | // attempt a connection | ||
| + | $dbh = pg_connect(" | ||
| + | if (!$dbh) { | ||
| + | | ||
| + | | ||
| + | |||
| + | // execute query | ||
| + | $sql = " | ||
| + | | ||
| + | if (!$result) { | ||
| + | | ||
| + | | ||
| + | |||
| + | // iterate over result set | ||
| + | // print each row | ||
| + | while ($row = pg_fetch_array($result)) { | ||
| + | echo " | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | // free memory | ||
| + | | ||
| + | |||
| + | // close connection | ||
| + | | ||
| + | ?> | ||
| + | |||
| + | </ | ||
| + | </ | ||
| </ | </ | ||
| + | |||
| + | <code php edit_data.php> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | |||
| + | <? | ||
| + | if ($_POST[' | ||
| + | // attempt a connection | ||
| + | $dbh = pg_connect(" | ||
| + | if (!$dbh) { | ||
| + | | ||
| + | } | ||
| + | | ||
| + | // escape strings in input data | ||
| + | $code = pg_escape_string($_POST[' | ||
| + | $name = pg_escape_string($_POST[' | ||
| + | | ||
| + | // execute query | ||
| + | $sql = " | ||
| + | | ||
| + | if (!$result) { | ||
| + | | ||
| + | } | ||
| + | | ||
| + | echo "Data successfully inserted!"; | ||
| + | | ||
| + | // free memory | ||
| + | | ||
| + | | ||
| + | // close connection | ||
| + | | ||
| + | } | ||
| + | ?> | ||
| + | |||
| + | <form action="<? | ||
| + | Country code: <br> <input type=" | ||
| + | <p> | ||
| + | Country name: <br> <input type=" | ||
| + | <p> | ||
| + | <input type=" | ||
| + | </ | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== Passwort zurücksetzen ===== | ||
| + | |||
| + | echo " | ||
| + | |||
| + | su - postgres | ||
| + | |||
| + | psql | ||
| + | |||
| + | CREATE USER root WITH PASSWORD ' | ||
| + | |||
| + | ALTER ROLE root SUPERUSER; | ||
| + | |||
| + | \q | ||
postgresql.1307272110.txt.gz · Zuletzt geändert: von admin
