2 //This is the ODBC Socket Server class PHP client class with sample usage
5 // Released into the public domain for version 0.90 of ODBC Socket Server
6 // http://odbc.linuxbox.com/
8 class ODBCSocketServer
{
9 var $sHostName; //name of the host to connect to
10 var $nPort; //port to connect to
11 var $sConnectionString; //connection string to use
13 //function to parse the SQL
14 function ExecSQL($sSQL) {
16 $fToOpen = fsockopen($this->sHostName
, $this->nPort
, &$errno, &$errstr, 30);
19 //contruct error string to return
20 $sReturn = "<?xml version=\"1.0\"?>\r\n<result state=\"failure\">\r\n<error>$errstr</error>\r\n</result>\r\n";
24 //construct XML to send
25 //search and replace HTML chars in SQL first
26 $sSQL = HTMLSpecialChars($sSQL);
27 $sSend = "<?xml version=\"1.0\"?>\r\n<request>\r\n<connectionstring>$this->sConnectionString</connectionstring>\r\n<sql>$sSQL</sql>\r\n</request>\r\n";
29 fputs($fToOpen, $sSend);
31 while (!feof($fToOpen))
33 $sReturn = $sReturn . fgets($fToOpen, 128);