summaryrefslogtreecommitdiff
path: root/includes/database.pgsql.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-06-05 12:13:23 +0000
committerDries Buytaert <dries@buytaert.net>2007-06-05 12:13:23 +0000
commit27388f66557cddce6aff1cc945601c5f843304cd (patch)
tree3a12f2afdc14b5af5be1b03d9c1fde6ac3d77928 /includes/database.pgsql.inc
parent745222200e0670f55c6d695e467558171b7bb5d8 (diff)
downloadbrdo-27388f66557cddce6aff1cc945601c5f843304cd.tar.gz
brdo-27388f66557cddce6aff1cc945601c5f843304cd.tar.bz2
- Patch #149176 by chx, David et al: getting rid of the sequences table, using db_last_insert_id() instead of db_next_id().
Diffstat (limited to 'includes/database.pgsql.inc')
-rw-r--r--includes/database.pgsql.inc24
1 files changed, 7 insertions, 17 deletions
diff --git a/includes/database.pgsql.inc b/includes/database.pgsql.inc
index deb6bfe58..399a72178 100644
--- a/includes/database.pgsql.inc
+++ b/includes/database.pgsql.inc
@@ -43,12 +43,6 @@ function db_version() {
/**
* Initialize a database connection.
- *
- * Note that you can change the pg_connect() call to pg_pconnect() if you
- * want to use persistent connections. This is not recommended on shared hosts,
- * and might require additional database/webserver tuning. It can increase
- * performance, however, when the overhead to connect to your database is high
- * (e.g. your database and web server live on different machines).
*/
function db_connect($url) {
// Check if MySQL support is present in PHP
@@ -258,19 +252,15 @@ function db_error() {
}
/**
- * Return a new unique ID in the given sequence.
- *
- * For compatibility reasons, Drupal does not use auto-numbered fields in its
- * database tables. Instead, this function is used to return a new unique ID
- * of the type requested. If necessary, a new sequence with the given name
- * will be created.
+ * Returns the last insert id. This function is thread safe.
*
- * Note that the table name should be in curly brackets to preserve compatibility
- * with table prefixes. For example, db_next_id('{node}_nid');
+ * @param $table
+ * The name of the table you inserted into.
+ * @param $field
+ * The name of the autoincrement field.
*/
-function db_next_id($name) {
- $id = db_result(db_query("SELECT nextval('%s_seq')", db_prefix_tables($name)));
- return $id;
+function db_last_insert_id($table, $field) {
+ return db_result(db_query("SELECT currval('%s_seq')", db_prefix_tables('{'. $table .'}') . '_'. $field));
}
/**