atom feed3 messages in net.php.lists.pear-cvs[PEAR-CVS] svn: /pear/packages/DB_Dat...
FromSent OnAttachments
Alan KnowlesJul 11, 2012 7:51 pm 
Alan KnowlesJul 11, 2012 7:58 pm 
Alan KnowlesJul 11, 2012 8:01 pm 
Subject:[PEAR-CVS] svn: /pear/packages/DB_DataObject/trunk/DB/DataObject/ Cast.php
From:Alan Knowles (ala@php.net)
Date:Jul 11, 2012 7:58:17 pm
List:net.php.lists.pear-cvs

alan_k Thu, 12 Jul 2012 02:58:28 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=326603

Log: fix #19500 - use same way that pear db mssql driver quotes for regular strings
(tidy up)

Bug: http://pear.php.net/bugs/19500 (unknown)

Changed paths: U pear/packages/DB_DataObject/trunk/DB/DataObject/Cast.php

Modified: pear/packages/DB_DataObject/trunk/DB/DataObject/Cast.php =================================================================== --- pear/packages/DB_DataObject/trunk/DB/DataObject/Cast.php 2012-07-12 02:52:06
UTC (rev 326602) +++ pear/packages/DB_DataObject/trunk/DB/DataObject/Cast.php 2012-07-12 02:58:28
UTC (rev 326603) @@ -396,7 +396,14 @@ return "'".sqlite_escape_string($this->value)."'";

case 'mssql': - return $this->escapeMSsql($this->value); + + if(is_numeric($this->value)) { + return $this->value; + } + $unpacked = unpack('H*hex', $this->value); + return '0x' . $unpacked['hex']; + +

default: return PEAR::raiseError("DB_DataObject_Cast cant handle blobs
for Database:{$db->dsn['phptype']} Yet"); @@ -441,7 +448,13 @@ return "'".mysqli_real_escape_string($db->connection,
$this->value)."'";

case 'mssql': - return $this->escapeMSsql($this->value); + // copied from the old DB mssql code...?? not sure how safe
this is. + return "'" . str_replace( + array("'", "\\\r\n", "\\\n"), + array("''", "\\\\\r\n\r\n", "\\\\\n\n"), + $this->value + ) . "'"; +

default: return PEAR::raiseError("DB_DataObject_Cast cant handle blobs
for Database:{$db->dsn['phptype']} Yet"); @@ -545,20 +558,8 @@ { return $this->value; } - /** - * workaround for lack of quoting in mssql api. - *
http://stackoverflow.com/questions/574805/how-to-escape-strings-in-mssql-using-php - * - */ - function escapeMSsql($data) - { - if(is_numeric($data)) { - return $data; - } - $unpacked = unpack('H*hex', $data); - return '0x' . $unpacked['hex']; - }