0

你如何在adodb中使用以下代码?

在哪里放置“'CharacterSet','UTF-8'”?

受保护的 $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;

}
4

2 回答 2

1

在创建 ADOdb 对象之后但在连接到数据库之前设置它。

$db = newADOConnection('mssqlnative');
$db->setConnectionParameter('CharacterSet', 'UTF-8');
$db->connect($host, $user, $password, $database);
于 2017-04-21T15:01:21.250 回答
0

'CharacterSet' 不适用于 mysqli。

正确一:

$db->setConnectionParameter(MYSQLI_SET_CHARSET_NAME, 'utf8');
于 2021-02-11T19:16:13.647 回答