use common_database_tablename instead of repeating that if structure everywhere

This commit is contained in:
Brenda Wallace 2009-03-17 10:36:12 +13:00
parent c2e529c72b
commit 18c8a55ba6
2 changed files with 14 additions and 6 deletions

View File

@ -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();

View File

@ -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;
}