Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0b5

Request #20010 Charset option in dsn
Submitted: 2013-07-15 16:08 UTC
From: dusty_it Assigned:
Status: Open Package: MDB2_Driver_sqlsrv (version 1.5.0b5)
PHP Version: Irrelevant OS: Windows
Roadmaps: (Not assigned)    
Subscription  


 [2013-07-15 16:08 UTC] dusty_it (Igor D'Astolfo)
Description: ------------ I'm working on porting an application to Windows + SQL Server as DB Backend. The driver works, I only found that specifying the "charset" option with sqlsrv driver raise an error, because the setCharset function is not defined in sqlsrv driver. As far as I know, it's not possible to change runtime the charset like in mysql, so I think it should suffice to set the option in $params array before the call to sqlsrv_connect and comment out the call to setCharset. Here follows a patch that I made: *** sqlsrv.php 2013-07-15 11:40:42.000000000 +0200 --- sqlsrv_patched.php 2013-07-15 11:40:38.000000000 +0200 *************** class MDB2_Driver_sqlsrv extends MDB2_Dr *** 330,335 **** --- 330,339 ---- if ($database) { $params['Database'] = $database; } + + if (!empty($this->dsn['charset'])) { + $params['CharacterSet'] = $this->dsn['charset']; + } if ($this->dsn['port'] && $this->dsn['port'] != 1433) { $host .= ','.$this->dsn['port']; *************** class MDB2_Driver_sqlsrv extends MDB2_Dr *** 344,356 **** $this->connected_database_name = $database; } - if (!empty($this->dsn['charset'])) { - $result = $this->setCharset($this->dsn['charset'], $connection); - if (MDB2::isError($result)) { - return $result; - } - } - if (empty($this->dsn['disable_iso_date'])) { @sqlsrv_query($connection,'SET DATEFORMAT ymd'); } --- 348,353 ----

Comments