<?xml version="1.0"?>
<?xml-stylesheet
href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"
?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel rdf:about="http://pear.php.net/bugs/search.php">
    <title>PEAR Bug Search Results</title>
    <link>http://pear.php.net/bugs/search.php?cmd=display&amp;package_name%5B0%5D=MDB2_Driver_sqlsrv</link>
    <description>Search Results</description>
    <dc:language>en-us</dc:language>
    <dc:creator>pear-webmaster@lists.php.net</dc:creator>
    <dc:publisher>pear-webmaster@lists.php.net</dc:publisher>
    <admin:generatorAgent rdf:resource="http://pear.php.net/bugs"/>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
    <items>
     <rdf:Seq>
      <rdf:li rdf:resource="http://pear.php.net/bug/20010" />
      <rdf:li rdf:resource="http://pear.php.net/bug/19737" />
      <rdf:li rdf:resource="http://pear.php.net/bug/19425" />
      <rdf:li rdf:resource="http://pear.php.net/bug/18524" />

     </rdf:Seq>
    </items>
  </channel>

  <image rdf:about="http://pear.php.net/gifs/pearsmall.gif">
    <title>PEAR Bugs</title>
    <url>http://pear.php.net/gifs/pearsmall.gif</url>
    <link>http://pear.php.net/bugs</link>
  </image>

    <item rdf:about="http://pear.php.net/bug/20010">
      <title>MDB2_Driver_sqlsrv: Feature/Change Request 20010 [Open] Charset option in dsn</title>
      <link>http://pear.php.net/bugs/20010</link>
      <content:encoded><![CDATA[<pre>MDB2_Driver_sqlsrv Feature/Change Request
Reported by dusty_it
2013-07-15T16:08:34+00:00
PHP: Irrelevant OS: Windows Package Version: 1.5.0b5

Description:
------------
I'm working on porting an application to Windows + SQL Server as DB 
Backend. The driver works, I only found that specifying the &quot;charset&quot; 
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-&gt;dsn['charset'])) {
+             $params['CharacterSet'] = $this-&gt;dsn['charset'];
+         }

           if ($this-&gt;dsn['port'] &amp;&amp; $this-&gt;dsn['port'] != 1433) {
               $host .= ','.$this-&gt;dsn['port'];
*************** class MDB2_Driver_sqlsrv extends MDB2_Dr
*** 344,356 ****
               $this-&gt;connected_database_name = $database;
           }

-         if (!empty($this-&gt;dsn['charset'])) {
-             $result = $this-&gt;setCharset($this-&gt;dsn['charset'], 
$connection);
-             if (MDB2::isError($result)) {
-                 return $result;
-             }
-         }
-
          if (empty($this-&gt;dsn['disable_iso_date'])) {
              @sqlsrv_query($connection,'SET DATEFORMAT ymd');
          }
--- 348,353 ----</pre>]]></content:encoded>
      <description><![CDATA[<pre>MDB2_Driver_sqlsrv Feature/Change Request
Reported by dusty_it
2013-07-15T16:08:34+00:00
PHP: Irrelevant OS: Windows Package Version: 1.5.0b5

Description:
------------
I'm working on porting an application to Windows + SQL Server as DB 
Backend. The driver works, I only found that specifying the &quot;charset&quot; 
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-&gt;dsn['charset'])) {
+             $params['CharacterSet'] = $this-&gt;dsn['charset'];
+         }

           if ($this-&gt;dsn['port'] &amp;&amp; $this-&gt;dsn['port'] != 1433) {
               $host .= ','.$this-&gt;dsn['port'];
*************** class MDB2_Driver_sqlsrv extends MDB2_Dr
*** 344,356 ****
               $this-&gt;connected_database_name = $database;
           }

-         if (!empty($this-&gt;dsn['charset'])) {
-             $result = $this-&gt;setCharset($this-&gt;dsn['charset'], 
$connection);
-             if (MDB2::isError($result)) {
-                 return $result;
-             }
-         }
-
          if (empty($this-&gt;dsn['disable_iso_date'])) {
              @sqlsrv_query($connection,'SET DATEFORMAT ymd');
          }
--- 348,353 ----</pre>]]></description>
      <dc:date>2013-07-15T16:08:34+00:00</dc:date>
      <dc:creator>dastolfo &amp;#x61;&amp;#116; smart &amp;#x64;&amp;#111;&amp;#x74; it</dc:creator>
      <dc:subject>MDB2_Driver_sqlsrv Feature/Change Request</dc:subject>
    </item>
    <item rdf:about="http://pear.php.net/bug/19737">
      <title>MDB2_Driver_sqlsrv: Bug 19737 [Open] fetchrow with MDB2_FETCHMODE_OBJECT</title>
      <link>http://pear.php.net/bugs/19737</link>
      <content:encoded><![CDATA[<pre>MDB2_Driver_sqlsrv Bug
Reported by ghada
2012-12-09T14:16:31+00:00
PHP: 5.3.8 OS: Windows 7 Package Version: 1.5.0b5

Description:
------------
Get the following error when fetching a row with MDB2_FETCHMODE_OBJECT:

Fatal error: Cannot use object of type stdClass as array in C:\xampp\php\PEAR\MDB2.php on line 1828


This error was worked around using code below:

Line 1824:
        case MDB2_PORTABILITY_RTRIM:
            foreach ($row as $key =&gt; $value) {
                if (is_string($value)) {
                    $row[$key] = rtrim($value);
                }
            }
            break;

Should be:

        case MDB2_PORTABILITY_RTRIM:
            foreach ($row as $key =&gt; $value) {
                if (is_string($value)) {
                    if (is_array($row))
                    {
                        $row[$key] = rtrim($value);
                    }
                    else
                    {
                        rtrim($row-&gt;$key);
                    }
                }
            }
            break;


Other issues still exist in MDB2 - with inserts.  Not sure if related.

Test script:
---------------
$sql = &quot;SELECT col1, col2
		FROM T1&quot;;

$result = $dbConn-&gt;query($sql);
if (MDB2::isError($result))
{
	die(&quot;error&quot;);
}

$row =&amp; $result-&gt;fetchRow(MDB2_FETCHMODE_OBJECT);	// generates error.


		




Expected result:
----------------
no errors.

Actual result:
--------------
Fatal error: Cannot use object of type stdClass as array in C:\xampp\php\PEAR\MDB2.php on line 1828</pre>]]></content:encoded>
      <description><![CDATA[<pre>MDB2_Driver_sqlsrv Bug
Reported by ghada
2012-12-09T14:16:31+00:00
PHP: 5.3.8 OS: Windows 7 Package Version: 1.5.0b5

Description:
------------
Get the following error when fetching a row with MDB2_FETCHMODE_OBJECT:

Fatal error: Cannot use object of type stdClass as array in C:\xampp\php\PEAR\MDB2.php on line 1828


This error was worked around using code below:

Line 1824:
        case MDB2_PORTABILITY_RTRIM:
            foreach ($row as $key =&gt; $value) {
                if (is_string($value)) {
                    $row[$key] = rtrim($value);
                }
            }
            break;

Should be:

        case MDB2_PORTABILITY_RTRIM:
            foreach ($row as $key =&gt; $value) {
                if (is_string($value)) {
                    if (is_array($row))
                    {
                        $row[$key] = rtrim($value);
                    }
                    else
                    {
                        rtrim($row-&gt;$key);
                    }
                }
            }
            break;


Other issues still exist in MDB2 - with inserts.  Not sure if related.

Test script:
---------------
$sql = &quot;SELECT col1, col2
		FROM T1&quot;;

$result = $dbConn-&gt;query($sql);
if (MDB2::isError($result))
{
	die(&quot;error&quot;);
}

$row =&amp; $result-&gt;fetchRow(MDB2_FETCHMODE_OBJECT);	// generates error.


		




Expected result:
----------------
no errors.

Actual result:
--------------
Fatal error: Cannot use object of type stdClass as array in C:\xampp\php\PEAR\MDB2.php on line 1828</pre>]]></description>
      <dc:date>2012-12-09T14:16:31+00:00</dc:date>
      <dc:creator>ghada &amp;#x61;&amp;#116; hpfm &amp;#x64;&amp;#111;&amp;#x74; com &amp;#x64;&amp;#111;&amp;#x74; au</dc:creator>
      <dc:subject>MDB2_Driver_sqlsrv Bug</dc:subject>
    </item>
    <item rdf:about="http://pear.php.net/bug/19425">
      <title>MDB2_Driver_sqlsrv: Feature/Change Request 19425 [Open] Add SSL option/functionality</title>
      <link>http://pear.php.net/bugs/19425</link>
      <content:encoded><![CDATA[<pre>MDB2_Driver_sqlsrv Feature/Change Request
Reported by hedroom
2012-05-18T22:27:01+00:00
PHP: 5.3.12 OS: Windows Package Version: 1.5.0b4

Description:
------------
I would like to propose that the ssl option (in the MDB2 documentation) be enabled to turn on encryption for the sqlsrv client.

I have uploaded a patch that has the code.

This would allow encrypted connections to MS-SQL servers that are setup to allow encrypted connections but are not forced...

Thank you,

Wade Hedgren</pre>]]></content:encoded>
      <description><![CDATA[<pre>MDB2_Driver_sqlsrv Feature/Change Request
Reported by hedroom
2012-05-18T22:27:01+00:00
PHP: 5.3.12 OS: Windows Package Version: 1.5.0b4

Description:
------------
I would like to propose that the ssl option (in the MDB2 documentation) be enabled to turn on encryption for the sqlsrv client.

I have uploaded a patch that has the code.

This would allow encrypted connections to MS-SQL servers that are setup to allow encrypted connections but are not forced...

Thank you,

Wade Hedgren</pre>]]></description>
      <dc:date>2012-05-18T22:27:01+00:00</dc:date>
      <dc:creator>wade &amp;#x61;&amp;#116; hedgren &amp;#x64;&amp;#111;&amp;#x74; org</dc:creator>
      <dc:subject>MDB2_Driver_sqlsrv Feature/Change Request</dc:subject>
    </item>
    <item rdf:about="http://pear.php.net/bug/18524">
      <title>MDB2_Driver_sqlsrv: Bug 18524 [Open] MDB2_PORTABILITY_FIX_CASE doesn't have any effect</title>
      <link>http://pear.php.net/bugs/18524</link>
      <content:encoded><![CDATA[<pre>MDB2_Driver_sqlsrv Bug
Reported by nickmc
2011-05-11T00:49:22+00:00
PHP: 5.3.6 OS: Windows Package Version: 1.5.0b3

Description:
------------
MDB2_PORTABILITY_FIX_CASE doesn't seem to do anything. 
I noticed this 
when I switched from the mssql driver to sqlsrv (the only 
change in my code to 
create the problem), and all my associative arrays ended up 
with undefined 
indexes because they now contained mixed case rather than 
being entirely 
lowercase.

I dug around a bit in MDB2\Driver\sqlsrv.php, and I found that 
the check for 
($fetchmode == MDB2_FETCHMODE_ASSOC) before applying 
MDB2_PORTABILITY_FIX_CASE was false although I specified 
MDB2_FETCHMODE_ASSOC. I checked the value for 
$fetchmode and it was 
MDB2_FETCHMODE_DEFAULT.

Adding the following code immediately before that check 
seemed to fix the 
problem, but I'm not sure whether it's the proper way to fix 
the problem, or if 
there are other implications. This is from fetchRow().

if($fetchmode == MDB2_FETCHMODE_DEFAULT)
   $fetchmode = $this-&gt;db-&gt;fetchmode;


The relevant section of code, altogether, is:
if($fetchmode == MDB2_FETCHMODE_DEFAULT)
			$fetchmode = $this-&gt;db-&gt;fetchmode;
		
        if ($fetchmode == MDB2_FETCHMODE_ASSOC &amp;&amp; 
is_array($row) &amp;&amp; 
$this-&gt;db-&gt;options['portability'] &amp; 
MDB2_PORTABILITY_FIX_CASE) {
			$row = array_change_key_case($row, $this-
&gt;db-
&gt;options['field_case']);
        }

Test script:
---------------
$mdb2 =&amp; MDB2::factory('sqlsrv://user:pass@server/Database');
$mdb2-&gt;setFetchMode(MDB2_FETCHMODE_ASSOC);
$mdb2-&gt;setOption('field_case', CASE_LOWER);
$mdb2-&gt;setOption('portability', MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL); 

$statement = $mdb2-&gt;prepare('select SomeRow from table');
$result = $statement-&gt;execute();

$data = $result-&gt;fetchAll();
var_dump($data);

Expected result:
----------------
// this is the output of the above script. notice that 
// SomeRow is not lowercase
array(1) {
  [0]=&gt;
  array(2) {
    [&quot;SomeRow &quot;]=&gt;
    string(4) &quot;1234&quot;
    [0]=&gt;
    string(4) &quot;1234&quot;
  }
}

Actual result:
--------------
array(1) {
  [0]=&gt;
  array(2) {
    [&quot;somerow&quot;]=&gt;
    string(4) &quot;1234&quot;
    [0]=&gt;
    string(4) &quot;1234&quot;
  }
}</pre>]]></content:encoded>
      <description><![CDATA[<pre>MDB2_Driver_sqlsrv Bug
Reported by nickmc
2011-05-11T00:49:22+00:00
PHP: 5.3.6 OS: Windows Package Version: 1.5.0b3

Description:
------------
MDB2_PORTABILITY_FIX_CASE doesn't seem to do anything. 
I noticed this 
when I switched from the mssql driver to sqlsrv (the only 
change in my code to 
create the problem), and all my associative arrays ended up 
with undefined 
indexes because they now contained mixed case rather than 
being entirely 
lowercase.

I dug around a bit in MDB2\Driver\sqlsrv.php, and I found that 
the check for 
($fetchmode == MDB2_FETCHMODE_ASSOC) before applying 
MDB2_PORTABILITY_FIX_CASE was false although I specified 
MDB2_FETCHMODE_ASSOC. I checked the value for 
$fetchmode and it was 
MDB2_FETCHMODE_DEFAULT.

Adding the following code immediately before that check 
seemed to fix the 
problem, but I'm not sure whether it's the proper way to fix 
the problem, or if 
there are other implications. This is from fetchRow().

if($fetchmode == MDB2_FETCHMODE_DEFAULT)
   $fetchmode = $this-&gt;db-&gt;fetchmode;


The relevant section of code, altogether, is:
if($fetchmode == MDB2_FETCHMODE_DEFAULT)
			$fetchmode = $this-&gt;db-&gt;fetchmode;
		
        if ($fetchmode == MDB2_FETCHMODE_ASSOC &amp;&amp; 
is_array($row) &amp;&amp; 
$this-&gt;db-&gt;options['portability'] &amp; 
MDB2_PORTABILITY_FIX_CASE) {
			$row = array_change_key_case($row, $this-
&gt;db-
&gt;options['field_case']);
        }

Test script:
---------------
$mdb2 =&amp; MDB2::factory('sqlsrv://user:pass@server/Database');
$mdb2-&gt;setFetchMode(MDB2_FETCHMODE_ASSOC);
$mdb2-&gt;setOption('field_case', CASE_LOWER);
$mdb2-&gt;setOption('portability', MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL); 

$statement = $mdb2-&gt;prepare('select SomeRow from table');
$result = $statement-&gt;execute();

$data = $result-&gt;fetchAll();
var_dump($data);

Expected result:
----------------
// this is the output of the above script. notice that 
// SomeRow is not lowercase
array(1) {
  [0]=&gt;
  array(2) {
    [&quot;SomeRow &quot;]=&gt;
    string(4) &quot;1234&quot;
    [0]=&gt;
    string(4) &quot;1234&quot;
  }
}

Actual result:
--------------
array(1) {
  [0]=&gt;
  array(2) {
    [&quot;somerow&quot;]=&gt;
    string(4) &quot;1234&quot;
    [0]=&gt;
    string(4) &quot;1234&quot;
  }
}</pre>]]></description>
      <dc:date>2012-04-01T20:09:24+00:00</dc:date>
      <dc:creator>nick &amp;#x61;&amp;#116; deltamotion &amp;#x64;&amp;#111;&amp;#x74; com</dc:creator>
      <dc:subject>MDB2_Driver_sqlsrv Bug</dc:subject>
    </item>
</rdf:RDF>
