use common_database_tablename instead of repeating that if structure everywhere
This commit is contained in:
parent
c2e529c72b
commit
18c8a55ba6
@ -116,15 +116,10 @@ class FeaturedAction extends Action
|
||||
$quoted[] = "'$nick'";
|
||||
}
|
||||
|
||||
$table = "user";
|
||||
if(common_config('db','quote_identifiers')) {
|
||||
$table = '"' . $table . '"';
|
||||
}
|
||||
|
||||
$user = new User;
|
||||
$user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted)));
|
||||
$user->limit(($this->page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
|
||||
$user->orderBy($table .'.nickname ASC');
|
||||
$user->orderBy(common_database_tablename('user') .'.nickname ASC');
|
||||
|
||||
$user->find();
|
||||
|
||||
|
13
lib/util.php
13
lib/util.php
@ -1300,3 +1300,16 @@ function common_compatible_license($from, $to)
|
||||
// XXX: better compatibility check needed here!
|
||||
return ($from == $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a quoted table name, if required according to config
|
||||
*/
|
||||
function common_database_tablename($tablename)
|
||||
{
|
||||
|
||||
if(common_config('db','quote_identifiers')) {
|
||||
$tablename = '"'. $tablename .'"';
|
||||
}
|
||||
//table prefixes could be added here later
|
||||
return $tablename;
|
||||
}
|
Loading…
Reference in New Issue
Block a user