ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:setcharset

setCharSet

Support for this command is limited to MySQL, Oracle, Interbase and Postgres databases. As of ADOdb V5.21, you can use the setConnectionParameter() parameter with any database that supports character set configuration.

Syntax
 bool function setCharSet(
      string $characterSetName
      )
      

Description

The function setCharSet() set the client side character set to the specified set. The function returns true or false based on the success of command execution.

Usage

$db->setCharset('utf8');

Workaround for setting server side character set on MySQL

$SQL = "SET 
    character_set_results    = 'utf8mb4',
    character_set_client     = 'utf8mb4', 
    character_set_connection = 'utf8mb4',
    character_set_database   = 'utf8mb4', 
    character_set_server     = 'utf8mb4'";
$db->execute($SQL);
v5/reference/connection/setcharset.txt · Last modified: 2018/06/11 10:14 by dregad