='); case 'set_charset' : return version_compare($version, '5.0.7', '>='); }; return false; } /** * Sets the MySQL connection's character set. * * @param resource $dbh The resource given by mysqli_connect * @param string $charset The character set (optional) * @param string $collate The collation (optional) * * @return bool True on success */ public static function setCharset($dbh, $charset = null, $collate = null) { $charset = (!isset($charset) ) ? $GLOBALS['DBCHARSET_DEFAULT'] : $charset; $collate = (!isset($collate) ) ? $GLOBALS['DBCOLLATE_DEFAULT'] : $collate; if (self::hasAbility($dbh, 'collation') && !empty($charset)) { if (function_exists('mysqli_set_charset') && self::hasAbility($dbh, 'set_charset')) { return mysqli_set_charset($dbh, $charset); } else { $sql = " SET NAMES {$charset}"; if (!empty($collate)) $sql .= " COLLATE {$collate}"; return mysqli_query($dbh, $sql); } } } } ?>