From e189e7d4c5adadf275071c5d4b28d31a1e2f953f Mon Sep 17 00:00:00 2001
From: ceb <ceb@alumni.egroupware.org>
Date: Mon, 2 Sep 2002 22:03:00 +0000
Subject: [PATCH] update add function to return the id

---
 phpgwapi/inc/class.categories.inc.php | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/phpgwapi/inc/class.categories.inc.php b/phpgwapi/inc/class.categories.inc.php
index 8740279eae..732bbc5d64 100644
--- a/phpgwapi/inc/class.categories.inc.php
+++ b/phpgwapi/inc/class.categories.inc.php
@@ -495,14 +495,14 @@
 				. "','" . $this->app_name . "','" . $cat_values['name'] . "','" . $cat_values['descr'] . "','" . $cat_values['data']
 				. "','" . $cat_values['main'] . "','" . $cat_values['level'] . "')",__LINE__,__FILE__);
 
+			$max = $this->db->get_last_insert_id('phpgw_categories','cat_id');
+
 			if (!$cat_values['parent'] || $cat_values['parent'] == 0)
 			{
-				$this->db->query("SELECT MAX(cat_id) FROM phpgw_categories",__LINE__,__FILE__);
-				$this->db->next_record();
-				$max = $this->db->f(0);
 				$this->db->query("UPDATE phpgw_categories SET cat_main='" . $max . "' WHERE cat_id='"
-					. $max . "'",__LINE__,__FILE__);
+								. $max . "'",__LINE__,__FILE__);
 			}
+			return $max;
 		}
 
 		/*!
@@ -518,7 +518,7 @@
 			}
 
 			$this->db->query("DELETE FROM phpgw_categories WHERE cat_id='$cat_id' $subdelete AND cat_appname='"
-				. $this->app_name . "'",__LINE__,__FILE__);
+							. $this->app_name . "'",__LINE__,__FILE__);
 		}
 
 		/*!