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()) {
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)) {
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;
}
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) {
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.
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;
}
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;
}
$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));
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.