4 * odbc.php - This is the ODBC Socket Server class PHP client class
5 * with sample usage at bottom.
7 * Released into the public domain for version 0.90 of ODBC Socket Server
8 * {@link http://odbc.linuxbox.com/}
10 * @copyright Copyright (c) 1999 Team FXML
11 * @license http://odbc.linuxbox.com/ public domain
16 * ODBC Socket Server class
18 class ODBCSocketServer
{
21 * Name of the host to connect to
22 * @var string $sHostName
31 * Connection string to use
32 * @var string $sConnectionString
34 var $sConnectionString;
38 * Function to parse the SQL
40 * @param string $sSQL The SQL statement to parse
43 function ExecSQL($sSQL) {
45 $fToOpen = fsockopen($this->sHostName
, $this->nPort
, &$errno, &$errstr, 30);
48 //contruct error string to return
49 $sReturn = "<?xml version=\"1.0\"?>\r\n<result state=\"failure\">\r\n<error>$errstr</error>\r\n</result>\r\n";
53 //construct XML to send
54 //search and replace HTML chars in SQL first
55 $sSQL = HTMLSpecialChars($sSQL);
56 $sSend = "<?xml version=\"1.0\"?>\r\n<request>\r\n<connectionstring>$this->sConnectionString</connectionstring>\r\n<sql>$sSQL</sql>\r\n</request>\r\n";
58 fputs($fToOpen, $sSend);
60 while (!feof($fToOpen))
62 $sReturn = $sReturn . fgets($fToOpen, 128);