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

Request #19500 Add support for mssql in DB_DataObject_Cast
Submitted: 2012-07-10 14:19 UTC
From: raziel057 Assigned:
Status: Open Package: DB_DataObject (version 1.10.0)
PHP Version: 5.3.14 OS: N/A
Roadmaps: (Not assigned)    
Subscription  


 [2012-07-10 14:19 UTC] raziel057 (Thomas Lallement)
Description: ------------ Hello, Could you add the following code in the DB_DataObject_Cast class (to support mssql) ? Please add following line in function toStringFromBlob($to,$db): case 'mssql': return mssql_escape($this->value); Please add following line in function toStringFromString($to,$db): case 'mssql': return "'".$this->value."'"; And add this function at the end of file: function mssql_escape($data) { if(is_numeric($data)) return $data; $unpacked = unpack('H*hex', $data); return '0x' . $unpacked['hex']; } I used the following thread to find the best proposed solution to escape blob for SQL Server. http://www.mehrdust.com/archives/insert-blob-into-mssql-using-php http://stackoverflow.com/questions/574805/how-to-escape-strings-in-mssql-using-php Thanks

Comments

 [2012-07-10 14:29 UTC] raziel057 (Thomas Lallement)
 [2012-07-12 09:09 UTC] alan_k (Alan Knowles)
I've commited to subversion the change. For the StringtoString, I've used the code from pear's mssql driver, otherwise it looks like the code could be exploitable. http://svn.php.net/viewvc/pear/packages/DB_DataObject/trunk/DB/DataObject/Cast. php?revision=326604&view=co Regards Alan