charset() static public method

Sets the charset for all queries The default and recommended charset is utf8
static public charset ( string $charset = 'utf8' ) : mixed
$charset string
return mixed
Exemplo n.º 1
0
 /** 
  * Sets the charset for all queries
  * The default and recommended charset is utf8
  *
  * @param  string $charset
  * @return mixed
  */
 static function charset($charset = 'utf8')
 {
     // check if there is a assigned charset and compare it
     if (self::$charset == $charset) {
         return true;
     }
     // set the new charset
     $set = @mysql_query('SET NAMES ' . $charset);
     if (!$set) {
         return self::error(l::get('db.errors.setting_charset_failed', 'Setting database charset failed'));
     }
     // save the new charset to the globals
     self::$charset = $charset;
     return $charset;
 }