Move BINARY modifier to make MYSQL use index again

release-0.6
thomascube 14 years ago
parent f1e98a453d
commit 7fb11ef6a9

@ -359,12 +359,11 @@ class rcube_user
$dbh = rcmail::get_instance()->get_dbh(); $dbh = rcmail::get_instance()->get_dbh();
// use BINARY (case-sensitive) comparison on MySQL, other engines are case-sensitive // use BINARY (case-sensitive) comparison on MySQL, other engines are case-sensitive
$prefix = preg_match('/^mysql/', $dbh->db_provider) ? 'BINARY ' : ''; $mod = preg_match('/^mysql/', $dbh->db_provider) ? 'BINARY' : '';
// query for matching user name // query for matching user name
$query = "SELECT * FROM ".get_table_name('users')." WHERE mail_host = ? AND %s = ?"; $query = "SELECT * FROM ".get_table_name('users')." WHERE mail_host = ? AND username = $mod ?";
$sql_result = $dbh->query($query, $host, $user);
$sql_result = $dbh->query(sprintf($query, $prefix.'username'), $host, $user);
// query for matching alias // query for matching alias
if (!($sql_arr = $dbh->fetch_assoc($sql_result))) { if (!($sql_arr = $dbh->fetch_assoc($sql_result))) {

Loading…
Cancel
Save