Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Fix query with compat MySQL 5.7. references #1807
Browse files Browse the repository at this point in the history
  • Loading branch information
David Durieux committed May 17, 2016
1 parent ec266a7 commit ff6e110
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions install/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -5837,15 +5837,19 @@ function plugin_fusioninventory_displayMigrationMessage ($id, $msg="") {
function changeDisplayPreference($olditemtype, $newitemtype) {
global $DB;

$query = "SELECT *, count(`id`) as `cnt` FROM `glpi_displaypreferences`
$query = "SELECT `users_id`, `num`, count(*) as `cnt` FROM `glpi_displaypreferences`
WHERE (`itemtype` = '".$newitemtype."'
OR `itemtype` = '".$olditemtype."')
group by `users_id`, `num`, `id`";
group by `users_id`, `num`";
$result=$DB->query($query);
while ($data=$DB->fetch_array($result)) {
if ($data['cnt'] > 1) {
$queryd = "DELETE FROM `glpi_displaypreferences`
WHERE `id`='".$data['id']."'";
WHERE (`itemtype` = '".$newitemtype."'
OR `itemtype` = '".$olditemtype."' "
. " AND `users_id`='".$data['users_id']."'"
. " AND `num`='".$data['num']."'"
. " LIMIT 1, 100";
$DB->query($queryd);
}
}
Expand Down Expand Up @@ -7666,15 +7670,19 @@ function update213to220_ConvertField($migration) {
function pluginFusioninventorychangeDisplayPreference($olditemtype, $newitemtype) {
global $DB;

$query = "SELECT *, count(`id`) as `cnt` FROM `glpi_displaypreferences`
$query = "SELECT `users_id`, `num`, count(*) as `cnt` FROM `glpi_displaypreferences`
WHERE (`itemtype` = '".$newitemtype."'
OR `itemtype` = '".$olditemtype."')
group by `users_id`, `num`, `id`";
group by `users_id`, `num`";
$result=$DB->query($query);
while ($data=$DB->fetch_array($result)) {
if ($data['cnt'] > 1) {
$queryd = "DELETE FROM `glpi_displaypreferences`
WHERE `id`='".$data['id']."'";
WHERE (`itemtype` = '".$newitemtype."'
OR `itemtype` = '".$olditemtype."' "
. " AND `users_id`='".$data['users_id']."'"
. " AND `num`='".$data['num']."'"
. " LIMIT 1, 100";
$DB->query($queryd);
}
}
Expand Down

0 comments on commit ff6e110

Please sign in to comment.