/[drupal]/contributions/sandbox/alex_b/mtk/helper/db_pg.inc
ViewVC logotype

Contents of /contributions/sandbox/alex_b/mtk/helper/db_pg.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Thu Aug 7 17:25:18 2008 UTC (15 months, 3 weeks ago) by alexb
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -0 lines
File MIME type: text/x-php
Add version string.
1 <?php
2 // $Id:$
3
4 /**
5 * Submits a query, creates connection if not present.
6 * @return result of pg_query() or FALSE;
7 */
8 function db_pg_query($query) {
9 static $conn;
10 if (!$conn) {
11 if (!$db_pg_url = variable_get('db_pg_url', FALSE)) {
12 drupal_set_message('Could not connect to PGSQL DB. Missing connection string $conf[\'db_pg_url\']', 'error');
13 return FALSE;
14 }
15 if (!$conn = pg_connect($db_pg_url)) {
16 drupal_set_message('Could not connect to PGSQL DB. '. pg_last_error(), 'error');
17 return FALSE;
18 }
19 }
20 if ($result = pg_query($conn, $query)) {
21 return $result;
22 }
23 drupal_set_message(pg_last_error($conn), 'error');
24 }

  ViewVC Help
Powered by ViewVC 1.1.2