Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix Sql query
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Nov 26, 2014
1 parent 3904e03 commit f4f4396
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions core/src/plugins/conf.sql/class.sqlConfDriver.php
Expand Up @@ -457,7 +457,7 @@ public function deleteRepository($repositoryId)
$children_results = dibi::query('SELECT * FROM [ajxp_roles] WHERE [serial_role] LIKE %~like~ GROUP BY [role_id]', '"'.$repositoryId.'";s:');
break;
default:
return "ERROR!, DB driver "+ $this->sqlDriver["driver"] +" not supported yet in __FUNCTION__";
return "ERROR!, DB driver ". $this->sqlDriver["driver"] ." not supported yet in __FUNCTION__";
}
$all = $children_results->fetchAll();
foreach ($all as $item) {
Expand Down Expand Up @@ -540,7 +540,7 @@ public function getRolesForRepository($repositoryId, $rolePrefix = '', $countOnl
}
break;
default:
return "ERROR!, DB driver "+ $this->sqlDriver["driver"] +" not supported yet in __FUNCTION__";
return "ERROR!, DB driver ". $this->sqlDriver["driver"] ." not supported yet in __FUNCTION__";
}
$all = $children_results->fetchAll();
foreach ($all as $item) {
Expand Down Expand Up @@ -584,7 +584,7 @@ public function countUsersForRepository($repositoryId, $details = false){
$q = 'SELECT count([role_id]) as c FROM [ajxp_roles] WHERE [role_id] LIKE \'AJXP_USR_/%\' AND [serial_role] LIKE %~like~';
break;
default:
return "ERROR!, DB driver "+ $this->sqlDriver["driver"] +" not supported yet in __FUNCTION__";
return "ERROR!, DB driver ". $this->sqlDriver["driver"] ." not supported yet in __FUNCTION__";
}
if($details){
if($this->sqlDriver["driver"] == "sqlite" || $this->sqlDriver["driver"] == "sqlite3"){
Expand Down Expand Up @@ -679,7 +679,7 @@ public function saveRoles($roles)
dibi::query("INSERT INTO [ajxp_roles] ([role_id],[serial_role]) VALUES (%s, %s)", $roleId, serialize($roleObject));
break;
default:
return "ERROR!, DB driver "+ $this->sqlDriver["driver"] +" not supported yet in __FUNCTION__";
return "ERROR!, DB driver " . $this->sqlDriver["driver"] . " not supported yet in __FUNCTION__";
}
}
}
Expand All @@ -692,23 +692,22 @@ public function updateRole($role, $userObject = null)
$row = dibi::query("SELECT [role_id] FROM [ajxp_roles] WHERE [role_id] like %s", $role->getId());
$res = $row->fetchSingle();

// If role exist => update into
if($res != null){
// If role exist => update into
switch ($this->sqlDriver["driver"]) {
case "sqlite":
case "sqlite3":
case "postgre":
dibi::query("UPDATE [ajxp_roles] SET [serial_role]=%b,[searchable_repositories]=%s WHERE [role_id] like %s", serialize($role), serialize($role->listAcls()), $role->getId());
dibi::query("UPDATE [ajxp_roles] SET [serial_role]=%b,[searchable_repositories]=%s WHERE [role_id] like %s", serialize($role), serialize($role->listAcls()), $role->getId());
break;
case "mysql":
dibi::query("UPDATE [ajxp_roles] SET [role_id]=%s,[serial_role]=%s WHERE [role_id] like %s", serialize($role), $role->getId());
dibi::query("UPDATE [ajxp_roles] SET [serial_role]=%s WHERE [role_id] like %s", serialize($role), $role->getId());
break;
default:
return "ERROR!, DB driver "+ $this->sqlDriver["driver"] +" not supported yet in __FUNCTION__";
return "ERROR!, DB driver " . $this->sqlDriver["driver"] ." not supported yet in __FUNCTION__";
}
}
// if role is not existed => insert into
else{
} else {
// if role is not existed => insert into
switch ($this->sqlDriver["driver"]) {
case "sqlite":
case "sqlite3":
Expand All @@ -719,7 +718,7 @@ public function updateRole($role, $userObject = null)
dibi::query("INSERT INTO [ajxp_roles] ([role_id],[serial_role]) VALUES (%s, %s)", $role->getId(), serialize($role));
break;
default:
return "ERROR!, DB driver "+ $this->sqlDriver["driver"] +" not supported yet in __FUNCTION__";
return "ERROR!, DB driver ". $this->sqlDriver["driver"] ." not supported yet in __FUNCTION__";
}
}
}
Expand Down

0 comments on commit f4f4396

Please sign in to comment.