Index: /trunk/include/dblayer/functions_mysql.inc.php
===================================================================
--- /trunk/include/dblayer/functions_mysql.inc.php	(revision 11990)
+++ /trunk/include/dblayer/functions_mysql.inc.php	(revision 11991)
@@ -351,13 +351,15 @@
  *
  * @param string table_name
- * @param array dbfields
- * @param array data
+ * @param array set_fields
+ * @param array where_fields
  * @param int flags - if MASS_UPDATES_SKIP_EMPTY - empty values do not overwrite existing ones
  * @return void
  */
-function single_update($tablename, $dbfields, $data, $flags=0)
-{
-  if (count($data) == 0)
+function single_update($tablename, $set_fields, $where_fields, $flags=0)
+{
+  if (count($set_fields) == 0)
+  {
     return;
+  }
 
   $query = '
@@ -365,11 +367,11 @@
   SET ';
   $is_first = true;
-  foreach ($dbfields['update'] as $key)
+  foreach ($set_fields as $key => $value)
   {
     $separator = $is_first ? '' : ",\n    ";
 
-    if (isset($data[$key]) and $data[$key] != '')
-    {
-      $query.= $separator.$key.' = \''.$data[$key].'\'';
+    if (isset($value) and $value != '')
+    {
+      $query.= $separator.$key.' = \''.$value.'\'';
     }
     else
@@ -386,5 +388,5 @@
   WHERE ';
     $is_first = true;
-    foreach ($dbfields['primary'] as $key)
+    foreach ($where_fields as $key => $value)
     {
       if (!$is_first)
@@ -392,7 +394,7 @@
         $query.= ' AND ';
       }
-      if ( isset($data[$key]) )
-      {
-        $query.= $key.' = \''.$data[$key].'\'';
+      if ( isset($value) )
+      {
+        $query.= $key.' = \''.$value.'\'';
       }
       else
@@ -472,5 +474,5 @@
 
 /**
- * inserts on line in a table
+ * inserts one line in a table
  *
  * @param string table_name
@@ -479,21 +481,27 @@
  * @return void
  */
-function single_insert($table_name, $dbfields, $insert)
-{
-  if (count($insert) != 0)
+function single_insert($table_name, $data)
+{
+  if (count($data) != 0)
   {
     $query = '
 INSERT INTO '.$table_name.'
-  ('.implode(',', $dbfields).')
+  ('.implode(',', array_keys($data)).')
   VALUES';
 
     $query .= '(';
-    foreach ($dbfields as $field_id => $dbfield)
-    {
-      if ($field_id > 0)
+    $is_first = true;
+    foreach ($data as $key => $value)
+    {
+      if (!$is_first)
       {
         $query .= ',';
       }
-      if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
+      else
+      {
+        $is_first = false;
+      }
+      
+      if ($value === '')
       {
         $query .= 'NULL';
@@ -501,5 +509,5 @@
       else
       {
-        $query .= "'".$insert[$dbfield]."'";
+        $query .= "'".$value."'";
       }
     }
Index: /trunk/include/dblayer/functions_pdo-sqlite.inc.php
===================================================================
--- /trunk/include/dblayer/functions_pdo-sqlite.inc.php	(revision 11990)
+++ /trunk/include/dblayer/functions_pdo-sqlite.inc.php	(revision 11991)
@@ -316,16 +316,18 @@
 
 /**
- * updates on line in a table
+ * updates one line in a table
  *
  * @param string table_name
- * @param array dbfields
- * @param array data
+ * @param array set_fields
+ * @param array where_fields
  * @param int flags - if MASS_UPDATES_SKIP_EMPTY - empty values do not overwrite existing ones
  * @return void
  */
-function single_update($tablename, $dbfields, $data, $flags=0)
-{
-  if (count($data) == 0)
+function single_update($tablename, $set_fields, $where_fields, $flags=0)
+{
+  if (count($set_fields) == 0)
+  {
     return;
+  }
 
   $query = '
@@ -333,11 +335,11 @@
   SET ';
   $is_first = true;
-  foreach ($dbfields['update'] as $key)
+  foreach ($set_fields as $key => $value)
   {
     $separator = $is_first ? '' : ",\n    ";
-    
-    if (isset($data[$key]) and $data[$key] != '')
-    {
-      $query.= $separator.$key.' = \''.$data[$key].'\'';
+
+    if (isset($value) and $value != '')
+    {
+      $query.= $separator.$key.' = \''.$value.'\'';
     }
     else
@@ -354,5 +356,5 @@
   WHERE ';
     $is_first = true;
-    foreach ($dbfields['primary'] as $key)
+    foreach ($where_fields as $key => $value)
     {
       if (!$is_first)
@@ -360,7 +362,7 @@
         $query.= ' AND ';
       }
-      if ( isset($data[$key]) )
-      {
-        $query.= $key.' = \''.$data[$key].'\'';
+      if ( isset($value) )
+      {
+        $query.= $key.' = \''.$value.'\'';
       }
       else
@@ -373,5 +375,4 @@
   }
 }
-
 
 /**
@@ -446,21 +447,27 @@
  * @return void
  */
-function single_insert($table_name, $dbfields, $insert)
-{
-  if (count($insert) != 0)
+function single_insert($table_name, $data)
+{
+  if (count($data) != 0)
   {
     $query = '
 INSERT INTO '.$table_name.'
-  ('.implode(',', $dbfields).')
+  ('.implode(',', array_keys($data)).')
   VALUES';
 
     $query .= '(';
-    foreach ($dbfields as $field_id => $dbfield)
-    {
-      if ($field_id > 0)
+    $is_first = true;
+    foreach ($data as $key => $value)
+    {
+      if (!$is_first)
       {
         $query .= ',';
       }
-      if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
+      else
+      {
+        $is_first = false;
+      }
+      
+      if ($value === '')
       {
         $query .= 'NULL';
@@ -468,5 +475,5 @@
       else
       {
-        $query .= "'".$insert[$dbfield]."'";
+        $query .= "'".$value."'";
       }
     }
Index: /trunk/include/dblayer/functions_pgsql.inc.php
===================================================================
--- /trunk/include/dblayer/functions_pgsql.inc.php	(revision 11990)
+++ /trunk/include/dblayer/functions_pgsql.inc.php	(revision 11991)
@@ -427,16 +427,18 @@
 
 /**
- * updates on line in a table
+ * updates one line in a table
  *
  * @param string table_name
- * @param array dbfields
- * @param array data
+ * @param array set_fields
+ * @param array where_fields
  * @param int flags - if MASS_UPDATES_SKIP_EMPTY - empty values do not overwrite existing ones
  * @return void
  */
-function single_update($tablename, $dbfields, $data, $flags=0)
-{
-  if (count($data) == 0)
+function single_update($tablename, $set_fields, $where_fields, $flags=0)
+{
+  if (count($set_fields) == 0)
+  {
     return;
+  }
 
   $query = '
@@ -444,11 +446,11 @@
   SET ';
   $is_first = true;
-  foreach ($dbfields['update'] as $key)
+  foreach ($set_fields as $key => $value)
   {
     $separator = $is_first ? '' : ",\n    ";
 
-    if (isset($data[$key]) and $data[$key] != '')
-    {
-      $query.= $separator.$key.' = \''.$data[$key].'\'';
+    if (isset($value) and $value != '')
+    {
+      $query.= $separator.$key.' = \''.$value.'\'';
     }
     else
@@ -465,5 +467,5 @@
   WHERE ';
     $is_first = true;
-    foreach ($dbfields['primary'] as $key)
+    foreach ($where_fields as $key => $value)
     {
       if (!$is_first)
@@ -471,7 +473,7 @@
         $query.= ' AND ';
       }
-      if ( isset($data[$key]) )
-      {
-        $query.= $key.' = \''.$data[$key].'\'';
+      if ( isset($value) )
+      {
+        $query.= $key.' = \''.$value.'\'';
       }
       else
@@ -482,5 +484,5 @@
     }
     pwg_query($query);
-  } 
+  }
 }
 
@@ -549,5 +551,5 @@
 
 /**
- * inserts on line in a table
+ * inserts one line in a table
  *
  * @param string table_name
@@ -556,21 +558,27 @@
  * @return void
  */
-function single_insert($table_name, $dbfields, $insert)
-{
-  if (count($insert) != 0)
+function single_insert($table_name, $data)
+{
+  if (count($data) != 0)
   {
     $query = '
 INSERT INTO '.$table_name.'
-  ('.implode(',', $dbfields).')
+  ('.implode(',', array_keys($data)).')
   VALUES';
 
     $query .= '(';
-    foreach ($dbfields as $field_id => $dbfield)
-    {
-      if ($field_id > 0)
+    $is_first = true;
+    foreach ($data as $key => $value)
+    {
+      if (!$is_first)
       {
         $query .= ',';
       }
-      if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
+      else
+      {
+        $is_first = false;
+      }
+      
+      if ($value === '')
       {
         $query .= 'NULL';
@@ -578,5 +586,5 @@
       else
       {
-        $query .= "'".$insert[$dbfield]."'";
+        $query .= "'".$value."'";
       }
     }
Index: /trunk/include/dblayer/functions_sqlite.inc.php
===================================================================
--- /trunk/include/dblayer/functions_sqlite.inc.php	(revision 11990)
+++ /trunk/include/dblayer/functions_sqlite.inc.php	(revision 11991)
@@ -328,16 +328,18 @@
 
 /**
- * updates on line in a table
+ * updates one line in a table
  *
  * @param string table_name
- * @param array dbfields
- * @param array data
+ * @param array set_fields
+ * @param array where_fields
  * @param int flags - if MASS_UPDATES_SKIP_EMPTY - empty values do not overwrite existing ones
  * @return void
  */
-function single_update($tablename, $dbfields, $data, $flags=0)
-{
-  if (count($data) == 0)
+function single_update($tablename, $set_fields, $where_fields, $flags=0)
+{
+  if (count($set_fields) == 0)
+  {
     return;
+  }
 
   $query = '
@@ -345,11 +347,11 @@
   SET ';
   $is_first = true;
-  foreach ($dbfields['update'] as $key)
+  foreach ($set_fields as $key => $value)
   {
     $separator = $is_first ? '' : ",\n    ";
-    
-    if (isset($data[$key]) and $data[$key] != '')
-    {
-      $query.= $separator.$key.' = \''.$data[$key].'\'';
+
+    if (isset($value) and $value != '')
+    {
+      $query.= $separator.$key.' = \''.$value.'\'';
     }
     else
@@ -366,5 +368,5 @@
   WHERE ';
     $is_first = true;
-    foreach ($dbfields['primary'] as $key)
+    foreach ($where_fields as $key => $value)
     {
       if (!$is_first)
@@ -372,7 +374,7 @@
         $query.= ' AND ';
       }
-      if ( isset($data[$key]) )
-      {
-        $query.= $key.' = \''.$data[$key].'\'';
+      if ( isset($value) )
+      {
+        $query.= $key.' = \''.$value.'\'';
       }
       else
@@ -385,5 +387,4 @@
   }
 }
-
 
 /**
@@ -458,21 +459,27 @@
  * @return void
  */
-function single_insert($table_name, $dbfields, $insert)
-{
-  if (count($insert) != 0)
+function single_insert($table_name, $data)
+{
+  if (count($data) != 0)
   {
     $query = '
 INSERT INTO '.$table_name.'
-  ('.implode(',', $dbfields).')
+  ('.implode(',', array_keys($data)).')
   VALUES';
 
     $query .= '(';
-    foreach ($dbfields as $field_id => $dbfield)
-    {
-      if ($field_id > 0)
+    $is_first = true;
+    foreach ($data as $key => $value)
+    {
+      if (!$is_first)
       {
         $query .= ',';
       }
-      if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
+      else
+      {
+        $is_first = false;
+      }
+      
+      if ($value === '')
       {
         $query .= 'NULL';
@@ -480,5 +487,5 @@
       else
       {
-        $query .= "'".$insert[$dbfield]."'";
+        $query .= "'".$value."'";
       }
     }
