Date: 04/25/00
- Next message: kk: "[PHPLIB-DEV] cvs commit"
- Previous message: Kristian Koehntopp: "Re: [PHPLIB-DEV] Comments in PHPLIB source code"
- Next in thread: kk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: kk
Date: Tue Apr 25 08:03:46 2000
Modified files:
php-lib/CHANGES
php-lib/php/db/pgsql/db_sql.inc
php-lib/php/ext/cart.inc
php-lib/php/ext/template.inc
Log message:
Several small changes in cart.inc and template.inc (please test).
Postgres nextid() support.
Index: php-lib/CHANGES
diff -u php-lib/CHANGES:1.174 php-lib/CHANGES:1.175
--- php-lib/CHANGES:1.174 Mon Apr 17 18:34:19 2000
+++ php-lib/CHANGES Tue Apr 25 08:03:44 2000
@@ -1,4 +1,9 @@
-$Id: CHANGES,v 1.174 2000/04/17 16:34:19 kk Exp $
+$Id: CHANGES,v 1.175 2000/04/25 06:03:44 kk Exp $
+
+25-Apr-2000 kk
+ - Applied pgsql nextid() patch.
+ - Small error correction in cart.inc.
+ - Small error correction in template.inc (untested).
17-Apr-2000 kk
- Applied $allowcache = "passive" patch after list discussion,
Index: php-lib/php/db/pgsql/db_sql.inc
diff -u php-lib/php/db/pgsql/db_sql.inc:1.1 php-lib/php/db/pgsql/db_sql.inc:1.2
--- php-lib/php/db/pgsql/db_sql.inc:1.1 Thu Apr 13 15:07:00 2000
+++ php-lib/php/db/pgsql/db_sql.inc Tue Apr 25 08:03:45 2000
@@ -5,7 +5,7 @@
* Copyright (c) 1998,1999 NetUSE GmbH
* Boris Erdmann, Kristian Koehntopp
*
- * $Id: db_sql.inc,v 1.1 2000/04/13 13:07:00 kk Exp $
+ * $Id: db_sql.inc,v 1.2 2000/04/25 06:03:45 kk Exp $
*
*/
@@ -20,6 +20,8 @@
var $Record = array();
var $Row = 0;
+ var $Seq_Table = "db_sequence";
+
var $Errno = 0;
var $Error = "";
@@ -91,6 +93,46 @@
function unlock() {
return pg_Exec($this->Link_ID, "commit");
}
+
+
+ /* public: sequence numbers */
+ function nextid($seq_name) {
+ $this->connect();
+
+ if ($this->lock($this->Seq_Table)) {
+ /* get sequence number (locked) and increment */
+ $q = sprintf("select nextid from %s where seq_name = '%s'",
+ $this->Seq_Table,
+ $seq_name);
+ $id = <email protected>($this->Link_ID, $q);
+ $res = <email protected>($id, 0);
+
+ /* No current value, make one */
+ if (!is_array($res)) {
+ $currentid = 0;
+ $q = sprintf("insert into %s values('%s', %s)",
+ $this->Seq_Table,
+ $seq_name,
+ $currentid);
+ $id = <email protected>($this->Link_ID, $q);
+ } else {
+ $currentid = $res["nextid"];
+ }
+ $nextid = $currentid + 1;
+ $q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
+ $this->Seq_Table,
+ $nextid,
+ $seq_name);
+ $id = <email protected>($this->Link_ID, $q);
+ $this->unlock();
+ } else {
+ $this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
+ return 0;
+ }
+ return $nextid;
+ }
+
+
function metadata($table) {
$count = 0;
Index: php-lib/php/ext/cart.inc
diff -u php-lib/php/ext/cart.inc:1.1 php-lib/php/ext/cart.inc:1.2
--- php-lib/php/ext/cart.inc:1.1 Thu Apr 13 15:28:48 2000
+++ php-lib/php/ext/cart.inc Tue Apr 25 08:03:45 2000
@@ -5,7 +5,7 @@
* Copyright (c) 1998,1999 NetUSE GmbH
* Boris Erdmann, Kristian Koehntopp
*
- * $Id: cart.inc,v 1.1 2000/04/13 13:28:48 kk Exp $
+ * $Id: cart.inc,v 1.2 2000/04/25 06:03:45 kk Exp $
*
*/
@@ -148,7 +148,7 @@
# Iterator to show cart contents.
#
function show_all() {
- if (!is_array($this->item) or ($this->item) == 0) {
+ if (!is_array($this->item) or $this->num_items() == 0) {
$this->show_empty_cart();
return false;
}
Index: php-lib/php/ext/template.inc
diff -u php-lib/php/ext/template.inc:1.1 php-lib/php/ext/template.inc:1.2
--- php-lib/php/ext/template.inc:1.1 Thu Apr 13 15:28:48 2000
+++ php-lib/php/ext/template.inc Tue Apr 25 08:03:45 2000
@@ -5,7 +5,7 @@
* (C) Copyright 1999 NetUSE GmbH
* Kristian Koehntopp
*
- * $Id: template.inc,v 1.1 2000/04/13 13:28:48 kk Exp $
+ * $Id: template.inc,v 1.2 2000/04/25 06:03:45 kk Exp $
*
*/
@@ -297,11 +297,11 @@
break;
case "remove":
- $str = preg_replace("/\\{[a-zA-Z0-9_]+\\}/", "", $str);
+ $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str);
break;
case "comment":
- $str = preg_replace("/\\{([a-zA-Z0-9_]+)\\}/", "<!-- Template $varname: Variable \\1 undefined -->", $str);
+ $str = preg_replace('/{[^ \t\r\n}]+}/', "<!-- Template $varname: Variable \\1 undefined -->", $str);
break;
}
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.
- Next message: kk: "[PHPLIB-DEV] cvs commit"
- Previous message: Kristian Koehntopp: "Re: [PHPLIB-DEV] Comments in PHPLIB source code"
- Next in thread: kk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

