0

How do you use the following code in adodb?

Where to put "'CharacterSet ',' UTF-8'"?

protected $connectionParameters = array();

/**
* Adds a parameter to the connection string.
*
* These parameters are added to the connection string when connecting,
* if the driver is coded to use it.
*
* @param    string  $parameter  The name of the parameter to set
* @param    string  $value      The value of the parameter
*
* @return null
*
* @example, for mssqlnative driver ('CharacterSet','UTF-8')
*/

    final public function setConnectionParameter($parameter,$value)
{

    $this->connectionParameters[$parameter] = $value;

}
Per
  • 1
  • 1
  • 2

2 Answers2

1

set it after you create the ADOdb object, but before you connection to the database.

$db = newADOConnection('mssqlnative');
$db->setConnectionParameter('CharacterSet', 'UTF-8');
$db->connect($host, $user, $password, $database);
Remo Harsono
  • 469
  • 9
  • 15
mnewnham
  • 70
  • 6
0

'CharacterSet' will not work for mysqli.

Correct one:

$db->setConnectionParameter(MYSQLI_SET_CHARSET_NAME, 'utf8');
santik
  • 346
  • 1
  • 12