]> wagnertech.de Git - timetracker.git/commitdiff
Refactoring, finished with last insert ids.
authorNik Okuntseff <support@anuko.com>
Fri, 30 Nov 2018 14:31:27 +0000 (14:31 +0000)
committerNik Okuntseff <support@anuko.com>
Fri, 30 Nov 2018 14:31:27 +0000 (14:31 +0000)
WEB-INF/lib/ttInvoiceHelper.class.php
WEB-INF/lib/ttOrgImportHelper.class.php
WEB-INF/lib/ttProjectHelper.class.php
WEB-INF/lib/ttRoleHelper.class.php
WEB-INF/lib/ttTaskHelper.class.php
WEB-INF/templates/footer.tpl

index 41dace01bfb86f17b0368105c53950f4e4ae954e..0867ee1ebc0ebbc5d186bf9efb72961570159c3f 100644 (file)
@@ -332,11 +332,7 @@ class ttInvoiceHelper {
     if (is_a($affected, 'PEAR_Error')) return false;
 
     // Mark associated invoice items with invoice id.
-    $last_id = 0;
-    $sql = "select last_insert_id() as last_insert_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_insert_id'];
+    $last_id = $mdb2->lastInsertID('tt_invoices', 'id');
 
     // Our update sql is different depending on tracking mode.
     if (MODE_TIME == $user->getTrackingMode()) {
index 011f2081dc0d23e6b38e359fe261113a16d81e14..328eabefbd5b7a52c35b9dec04717c2bfebda6ec 100644 (file)
@@ -725,11 +725,7 @@ class ttOrgImportHelper {
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-    $last_id = 0;
-    $sql = "select last_insert_id() as last_insert_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_insert_id'];
+    $last_id = $mdb2->lastInsertID('tt_projects', 'id');
 
     // Insert binds into tt_project_task_binds table.
     if (is_array($tasks)) {
@@ -764,10 +760,7 @@ class ttOrgImportHelper {
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-    $sql = "SELECT LAST_INSERT_ID() AS last_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_id'];
+    $last_id = $mdb2->lastInsertID('tt_roles', 'id');
     return $last_id;
   }
 
@@ -796,11 +789,7 @@ class ttOrgImportHelper {
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-    $last_id = 0;
-    $sql = "select last_insert_id() as last_insert_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_insert_id'];
+    $last_id = $mdb2->lastInsertID('tt_clients', 'id');
 
     if (count($projects) > 0)
       foreach ($projects as $p_id) {
@@ -844,13 +833,8 @@ class ttOrgImportHelper {
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-    $sql = "select last_insert_id() as last_id";
-    $res = $mdb2->query($sql);
-    if (is_a($res, 'PEAR_Error'))
-      return false;
-
-    $val = $res->fetchRow();
-    return $val['last_id'];
+    $last_id = $mdb2->lastInsertID('tt_fav_reports', 'id');
+    return $last_id;
   }
 
   // insertNotification function inserts a new notification into database.
@@ -912,11 +896,7 @@ class ttOrgImportHelper {
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-    $last_id = 0;
-    $sql = "select last_insert_id() as last_insert_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_insert_id'];
+    $last_id = $mdb2->lastInsertID('tt_custom_fields', 'id');
     return $last_id;
   }
 
@@ -935,11 +915,7 @@ class ttOrgImportHelper {
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-    $last_id = 0;
-    $sql = "select last_insert_id() as last_insert_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_insert_id'];
+    $last_id = $mdb2->lastInsertID('tt_custom_field_options', 'id');
     return $last_id;
   }
 
index 2a439dd9fda52b0409be76d2b6210666fef0bf2d..98d928f968887979ba26e61dbf36b4265c5e2898 100644 (file)
@@ -206,12 +206,8 @@ class ttProjectHelper {
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error'))
       return false;
-    
-    $last_id = 0;
-    $sql = "select last_insert_id() as last_insert_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_insert_id'];
+
+    $last_id = $mdb2->lastInsertID('tt_projects', 'id');
 
     // Bind the project to users.
     $active_users = ttTeamHelper::getActiveUsers(array('getAllFields'=>true));
index c14bc970f45a36d5bc57a6cfdfcf14f4f3a4e157..0686b1cdf78b98739f7604ccdca36279e631fca4 100644 (file)
@@ -173,10 +173,7 @@ class ttRoleHelper {
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-    $sql = "SELECT LAST_INSERT_ID() AS last_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_id'];
+    $last_id = $mdb2->lastInsertID('tt_roles', 'id');
     return $last_id;
   }
 
index 0d4d5eff4ff50d3664ac2a9f21a1e769a78d767d..2987d2781602d2e6c4863bc6e8c26e861f10b144 100644 (file)
@@ -153,11 +153,8 @@ class ttTaskHelper {
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-    $sql = "select last_insert_id() as last_insert_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_insert_id'];
-    
+    $last_id = $mdb2->lastInsertID('tt_tasks', 'id');
+
     if (is_array($projects)) {
       foreach ($projects as $p_id) {
         // Insert task binds into tt_project_task_binds table.
index c1615800249cd3e02b26c25501a9bf5625d5d09e..0b4dd2b45c972460d3da187e9524458fee4b1ee3 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.28.4545 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.28.4546 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>