Skip to content

Commit

Permalink
Merge branch 'hartmut-php/no-mysql-functions'
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Sep 27, 2014
2 parents b761c94 + 9614940 commit 312b0d0
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/eventum/class.custom_field.php
Expand Up @@ -1747,7 +1747,7 @@ public static function getDBValueFieldNameByType($type)

public function getDBValueFieldSQL()
{
return "(IF(fld_type = 'date', icf_value_date, IF(fld_type = 'integer', icf_value_integer, icf_value)))";
return "(CASE WHEN fld_type = 'date' THEN icf_value_date ELSE WHEN fld_type = 'integer' THEN icf_value_integer ELSE icf_value END)";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/eventum/class.draft.php
Expand Up @@ -397,7 +397,7 @@ public function getDraftBySequence($issue_id, $sequence)
emd_status = 'pending'
ORDER BY
emd_id ASC
LIMIT " . ($sequence - 1) . ", 1";
LIMIT 1 OFFSET " . ($sequence - 1);
$res = DB_Helper::getInstance()->getOne($stmt);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
Expand Down
2 changes: 1 addition & 1 deletion lib/eventum/class.email_account.php
Expand Up @@ -428,7 +428,7 @@ public static function getEmailAccount($prj_id = false)
WHERE
ema_prj_id=" . Misc::escapeInteger($prj_id) . "
LIMIT
0, 1";
1 OFFSET 0";
$res = DB_Helper::getInstance()->getOne($stmt);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
Expand Down
9 changes: 3 additions & 6 deletions lib/eventum/class.mail_queue.php
Expand Up @@ -307,12 +307,9 @@ private function _getList($status, $limit = false)
WHERE
maq_status='$status'
ORDER BY
maq_id ASC";

if ($limit !== false) {
$sql .= " LIMIT 0, $limit";
}

maq_id ASC
LIMIT
$limit OFFSET 0";
$res = DB_Helper::getInstance()->getCol($sql);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
Expand Down
2 changes: 1 addition & 1 deletion lib/eventum/class.news.php
Expand Up @@ -51,7 +51,7 @@ public function getListByProject($prj_id, $show_full_message = false)
ORDER BY
nws_created_date DESC
LIMIT
0, 3";
3 OFFSET 0";
$res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
Expand Down
2 changes: 1 addition & 1 deletion lib/eventum/class.note.php
Expand Up @@ -244,7 +244,7 @@ public function getNoteBySequence($issue_id, $sequence)
not_removed = 0
ORDER BY
not_created_date ASC
LIMIT " . ($sequence - 1) . ", 1";
LIMIT 1 OFFSET " . ($sequence - 1);
$res = DB_Helper::getInstance()->getOne($stmt);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
Expand Down
2 changes: 1 addition & 1 deletion lib/eventum/class.notification.php
Expand Up @@ -72,7 +72,7 @@ public static function isSubscribedToEmails($issue_id, $email)
public static function getSubscribedEmails($issue_id, $type = false)
{
$stmt = "SELECT
IF(usr_id <> 0, usr_email, sub_email) AS email
CASE usr_id <> 0 THEN usr_email ELSE sub_email END AS email
FROM
(
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription";
Expand Down
2 changes: 1 addition & 1 deletion lib/eventum/class.report.php
Expand Up @@ -890,7 +890,7 @@ public function getWorkloadByDateRange($interval, $type, $start, $end, $category
break;
case "dow":
$format = '%W';
$order_by = "IF(DATE_FORMAT(%1\$s, '%%w') = 0, 7, DATE_FORMAT(%1\$s, '%%w'))";
$order_by = "CASE WHEN DATE_FORMAT(%1\$s, '%%w') = 0 THEN 7 ELSE DATE_FORMAT(%1\$s, '%%w') END";
break;
case "week":
if ($type == "aggregate") {
Expand Down
4 changes: 2 additions & 2 deletions lib/eventum/class.search.php
Expand Up @@ -265,7 +265,7 @@ public static function getListing($prj_id, $options, $current_row = 0, $max = 5)
iss_last_internal_action_date,
iss_last_internal_action_type,
" . Issue::getLastActionFields() . ",
IF(iss_last_internal_action_date > iss_last_public_action_date, 'internal', 'public') AS action_type,
CASE WHEN iss_last_internal_action_date > iss_last_public_action_date THEN 'internal' ELSE 'public' END AS action_type,
iss_private,
usr_full_name,
iss_percent_complete,
Expand Down Expand Up @@ -397,7 +397,7 @@ public static function getListing($prj_id, $options, $current_row = 0, $max = 5)
$total_rows = Pager::getTotalRows($stmt);
$stmt .= "
LIMIT
" . Misc::escapeInteger($start) . ", " . Misc::escapeInteger($max);
" . Misc::escapeInteger($max) . " OFFSET " . Misc::escapeInteger($start);
$res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
Expand Down
18 changes: 9 additions & 9 deletions lib/eventum/class.stats.php
Expand Up @@ -230,8 +230,8 @@ public function getCategory($hide_closed = false)
$stmt = "SELECT
DISTINCT iss_prc_id,
prc_title,
SUM(IF(sta_is_closed=0, 1, 0)) AS total_open_items,
SUM(IF(sta_is_closed=1, 1, 0)) AS total_closed_items
SUM(CASE WHEN sta_is_closed=0 THEN 1 ELSE 0 END) AS total_open_items,
SUM(CASE WHEN sta_is_closed=1 THEN 1 ELSE 0 END) AS total_closed_items
FROM
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category,
Expand Down Expand Up @@ -272,8 +272,8 @@ public function getRelease($hide_closed = false)
$stmt = "SELECT
DISTINCT iss_pre_id,
pre_title,
SUM(IF(sta_is_closed=0, 1, 0)) AS total_open_items,
SUM(IF(sta_is_closed=1, 1, 0)) AS total_closed_items
SUM(CASE WHEN sta_is_closed=0 THEN 1 ELSE 0 END) AS total_open_items,
SUM(CASE WHEN sta_is_closed=1 THEN 1 ELSE 0 END) AS total_closed_items
FROM
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_release,
Expand Down Expand Up @@ -350,8 +350,8 @@ public function getPriority($hide_closed = false)
$stmt = "SELECT
DISTINCT iss_pri_id,
pri_title,
SUM(IF(sta_is_closed=0, 1, 0)) AS total_open_items,
SUM(IF(sta_is_closed=1, 1, 0)) AS total_closed_items
SUM(CASE WHEN sta_is_closed=0 THEN 1 ELSE 0 END) AS total_open_items,
SUM(CASE WHEN sta_is_closed=1 THEN 1 ELSE 0 END) AS total_closed_items
FROM
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority,
Expand Down Expand Up @@ -430,8 +430,8 @@ public function getUser($hide_closed = false)
$stmt = "SELECT
DISTINCT isu_usr_id,
usr_full_name,
SUM(IF(sta_is_closed=0, 1, 0)) AS total_open_items,
SUM(IF(sta_is_closed=1, 1, 0)) AS total_closed_items
SUM(CASE WHEN sta_is_closed=0 THEN 1 ELSE 0 END) AS total_open_items,
SUM(CASE WHEN sta_is_closed=1 THEN 1 ELSE 0 END) AS total_closed_items
FROM
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,
Expand Down Expand Up @@ -471,7 +471,7 @@ public function getEmailStatus()
{
$prj_id = Auth::getCurrentProject();
$stmt = "SELECT
IF(sup_iss_id > 0, 'associated', 'unassociated') type,
CASE WHEN sup_iss_id > 0 THEN 'associated' ELSE 'unassociated' END AS type,
COUNT(*) AS total_items
FROM
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email,
Expand Down
4 changes: 2 additions & 2 deletions lib/eventum/class.support.php
Expand Up @@ -1308,7 +1308,7 @@ public function getEmailListing($options, $current_row = 0, $max = 5)
$total_rows = Pager::getTotalRows($stmt);
$stmt .= "
LIMIT
" . Misc::escapeInteger($start) . ", " . Misc::escapeInteger($max);
" . Misc::escapeInteger($max) . " OFFSET " . Misc::escapeInteger($start);
$res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
Expand Down Expand Up @@ -1658,7 +1658,7 @@ public function getEmailBySequence($issue_id, $sequence)
sup_iss_id = " . Misc::escapeInteger($issue_id) . "
ORDER BY
sup_id
LIMIT " . (Misc::escapeInteger($sequence) - 1) . ", 1";
LIMIT 1 OFFSET " . (Misc::escapeInteger($sequence) - 1);
$res = DB_Helper::getInstance()->getRow($stmt);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
Expand Down

0 comments on commit 312b0d0

Please sign in to comment.