Пример #1
0
function register_db_api($name, $args)
{
    $db_api = DB_API::get_instance();
    $db_api->register_db($name, $args);
}
Пример #2
0
 /**
  * Method used to generate a where clause from the given list of conditions.
  *
  * @access  public
  * @param   array $reminder An array of reminder info.
  * @param   array $conditions The list of conditions
  * @return  string The where clause
  */
 function getWhereClause($reminder, $conditions)
 {
     $stmt = '
               WHERE
                 iss_prj_id=' . $reminder['rem_prj_id'] . "\n";
     $requirement = Reminder::getRequirements($reminder['rem_id']);
     if ($requirement['type'] == 'issue') {
         $stmt .= ' AND iss_id IN (' . implode(', ', $requirement['values']) . ")\n";
     } else {
         if (Customer::hasCustomerIntegration($reminder['rem_prj_id'])) {
             if ($requirement['type'] == 'customer') {
                 $stmt .= ' AND iss_customer_id IN (' . implode(', ', $requirement['values']) . ")\n";
             } elseif ($requirement['type'] == 'support_level') {
                 if (Customer::doesBackendUseSupportLevels($reminder['rem_prj_id'])) {
                     $customer_ids = Customer::getListBySupportLevel($reminder['rem_prj_id'], $requirement['values'], CUSTOMER_EXCLUDE_EXPIRED);
                     // break the query on purpose if no customers could be found
                     if (count($customer_ids) == 0) {
                         $customer_ids = array(-1);
                     }
                     $stmt .= ' AND iss_customer_id IN (' . implode(', ', $customer_ids) . ")\n";
                 }
             }
         }
     }
     $priorities = Reminder::getAssociatedPriorities($reminder['rem_id']);
     if (count($priorities) > 0) {
         $stmt .= ' AND iss_pri_id IN (' . implode(', ', $priorities) . ")\n";
     }
     // now for the interesting stuff
     for ($i = 0; $i < count($conditions); $i++) {
         // check for fields that compare to other fields
         if (!empty($conditions[$i]['rlc_comparison_rmf_id'])) {
             $sql_field = Reminder_Condition::getSQLField($conditions[$i]['rlc_comparison_rmf_id']);
             $stmt .= sprintf(" AND %s %s %s\n", $conditions[$i]['rmf_sql_field'], $conditions[$i]['rmo_sql_representation'], $sql_field);
         } else {
             // date field values are always saved as number of hours, so let's calculate them now as seconds
             if (stristr($conditions[$i]['rmf_title'], 'date')) {
                 // support NULL as values for a date field
                 if (strtoupper($conditions[$i]['rlc_value']) == 'NULL') {
                     $conditions[$i]['rmf_sql_representation'] = $conditions[$i]['rmf_sql_field'];
                 } else {
                     $conditions[$i]['rlc_value'] = $conditions[$i]['rlc_value'] * 60 * 60;
                     if (@$reminder["rem_skip_weekend"] == 1) {
                         $sql_field = Reminder_Condition::getSQLField($conditions[$i]['rlc_rmf_id']);
                         $conditions[$i]['rmf_sql_representation'] = DB_API::getNoWeekendDateDiffSQL($sql_field);
                     }
                 }
             }
             $stmt .= sprintf(" AND %s %s %s\n", $conditions[$i]['rmf_sql_representation'], $conditions[$i]['rmo_sql_representation'], $conditions[$i]['rlc_value']);
         }
     }
     return $stmt;
 }