Possible PEAR::DB portability problem

From: Date: Wed, 06 Nov 2002 09:07:30 +0000
Subject: Possible PEAR::DB portability problem
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-10495@lists.php.net to get a copy of this message
Hi there, I´ve encountered a problem with PEAR::DB´s autoExecute() method. I have an application that was initially built to run with MySQL, but that I already prepared to be able to use other databases as well. autoExecute is used for all insert and update queries to ease source readability and integration/renaming of data fields. Today I wanted to connect to Microsoft SQL Server 2000 - and nothing works anymore. The problem is that in some cases, MSSQL insists that numeric values are being passed without quotes, while autoExecute automagically wraps them around each value (except for NULL values). So I thought I could just rewrite DB´s quote method like this: function quote($string) { if ($string === null) { return 'null'; } if (is_string($string)) { return ("'".str_replace("'", "''", $string)."'"); } return $string; } This way, only string values are being put into quotes. However, when I pass an Array like this to autoExecute: array('field1' => (int) intVal, 'field2' => (string) strVal, 'field3' => (float) dblVal, 'field4' => null); ..then all values except for the null value are at some point being converted to strings, so my modification of the quote method is useless. I have solved my problem by writing my own query builder function, but I think this might become an issue for others as well. I´ve not yet found the point in DB´s code where the conversion is made. Regards, Markus -- *21st Media* | Consulting, Konzeption, Produktion für die Bereiche: Markus Wolff | Internet, Intranet, eCommerce, Content Management, Hamburg,Germany | Softwareentwicklung, 3D-Animation, Videostreaming http://21st.de | Tel. [+49](0)40/6887949-0, Fax: [+49](0)40/6887949-1

« previous php.pear.dev (#10495) next »