calendar/lib: calendar_set_filters() use pre-fetched context and course recs
[moodle-pu.git] / lib / odbc.php
blobc8830c59644688231d36d2d8176bcd2d68ca1781
1 <?php
3 /**
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/}
9 * @author Team FXML
10 * @copyright Copyright (c) 1999 Team FXML
11 * @license http://odbc.linuxbox.com/ public domain
12 * @package moodlecore
15 /**
16 * ODBC Socket Server class
18 class ODBCSocketServer {
20 /**
21 * Name of the host to connect to
22 * @var string $sHostName
24 var $sHostName;
25 /**
26 * Port to connect to
27 * @var int $nPort
29 var $nPort;
30 /**
31 * Connection string to use
32 * @var string $sConnectionString
34 var $sConnectionString;
36 //
37 /**
38 * Function to parse the SQL
40 * @param string $sSQL The SQL statement to parse
41 * @return string
43 function ExecSQL($sSQL) {
45 $fToOpen = fsockopen($this->sHostName, $this->nPort, &$errno, &$errstr, 30);
46 if (!$fToOpen)
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";
51 else
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";
57 //write request
58 fputs($fToOpen, $sSend);
59 //now read response
60 while (!feof($fToOpen))
62 $sReturn = $sReturn . fgets($fToOpen, 128);
64 fclose($fToOpen);
66 return $sReturn;
68 }//class