That is hard to read because poorly formatted, but:
$GLOBALS['MySQL']->getAllWithKey(
"SELECT `ta`.`ID` AS `id`,
`ta`.`Name` AS `title`,
`tm`.`AllowedCount`,
`tm`.`AllowedPeriodLen`
FROM `sys_acl_actions` AS `ta`
LEFT JOIN `sys_acl_matrix` AS `tm` ON `ta`.`ID` = `tm`.`IDAction`
LEFT JOIN `sys_acl_levels` AS `tl` ON `tm`.`IDLevel` = `tl`.`ID`
WHERE `tl`.`ID`='" . $iMembId . "'
ORDER BY `ta`.`Name`", "id");
I would probably do away with all the backquotes, and make sure that the schema was also case-insensitive, but I've kept them for consistency with the question.
You also have an SQL injection possibility with the use of $iMembId
in the WHERE clause - if the users supplied the data in the variable, you must sanitize it before adding it to your SQL (Remember Little Bobby Tables!). Ideally, you'd use a placeholder (usually a question mark) and provide the value of $iMembId
as the associated value when you execute the SQL.
Without those backquotes, it becomes:
$GLOBALS['MySQL']->getAllWithKey(
"SELECT ta.ID AS id,
ta.Name AS title,
tm.AllowedCount,
tm.AllowedPeriodLen
FROM sys_acl_actions AS ta
LEFT JOIN sys_acl_matrix AS tm ON ta.ID = tm.IDAction
LEFT JOIN sys_acl_levels AS tl ON tm.IDLevel = tl.ID
WHERE tl.ID = '" . $iMembId . "'
ORDER BY ta.Name", "id");
Note, though, that the quotes preserve the case of the identifiers inside, so you would probably have to modify your schema before the quoteless version works.