@@ -719,8 +719,8 @@ public function datalogSave($db_table, $action, $primary_field, $primary_id, $re
719719 if ($ action == 'INSERT ' ) $ action = 'i ' ;
720720 if ($ action == 'UPDATE ' ) $ action = 'u ' ;
721721 if ($ action == 'DELETE ' ) $ action = 'd ' ;
722- $ sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES (?, ?, ?, ?, ?, ?, ?) " ;
723- $ app ->db ->query ($ sql , $ db_table , $ dbidx , $ server_id , $ action , time (), $ username , $ diffstr );
722+ $ sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data,session_id ) VALUES (?, ?, ?, ?, ?, ?, ?, ?) " ;
723+ $ app ->db ->query ($ sql , $ db_table , $ dbidx , $ server_id , $ action , time (), $ username , $ diffstr, session_id () );
724724 }
725725
726726 return true ;
@@ -759,6 +759,9 @@ public function datalogInsert($tablename, $insert_data, $index_field) {
759759
760760 $ old_rec = array ();
761761 $ index_value = $ this ->insertID ();
762+ if (!$ index_value && isset ($ insert_data [$ index_field ])) {
763+ $ index_value = $ insert_data [$ index_field ];
764+ }
762765 $ new_rec = $ this ->queryOneRecord ("SELECT * FROM ?? WHERE ?? = ? " , $ tablename , $ index_field , $ index_value );
763766 $ this ->datalogSave ($ tablename , 'INSERT ' , $ index_field , $ index_value , $ old_rec , $ new_rec );
764767
0 commit comments