Automatic installer lang files (20110214)
[moodle.git] / lib / odbc.php
blob3c773a33287a12ba9c59f425c6592871c967aaef
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 *
10 * @package moodlecore
11 * @author Team FXML
12 * @copyright Copyright (c) 1999 Team FXML
13 * @license http://odbc.linuxbox.com/ public domain
16 /**
17 * ODBC Socket Server class
19 * @package moodlecore
20 * @copyright Copyright (c) 1999 Team FXML
21 * @license http://odbc.linuxbox.com/ public domain
23 class ODBCSocketServer {
25 /**
26 * Name of the host to connect to
27 * @var string $sHostName
29 var $sHostName;
30 /**
31 * Port to connect to
32 * @var int $nPort
34 var $nPort;
35 /**
36 * Connection string to use
37 * @var string $sConnectionString
39 var $sConnectionString;
41 //
42 /**
43 * Function to parse the SQL
45 * @param string $sSQL The SQL statement to parse
46 * @return string
48 function ExecSQL($sSQL) {
50 $fToOpen = fsockopen($this->sHostName, $this->nPort, &$errno, &$errstr, 30);
51 if (!$fToOpen)
53 //contruct error string to return
54 $sReturn = "<?xml version=\"1.0\"?>\r\n<result state=\"failure\">\r\n<error>$errstr</error>\r\n</result>\r\n";
56 else
58 //construct XML to send
59 //search and replace HTML chars in SQL first
60 $sSQL = HTMLSpecialChars($sSQL);
61 $sSend = "<?xml version=\"1.0\"?>\r\n<request>\r\n<connectionstring>$this->sConnectionString</connectionstring>\r\n<sql>$sSQL</sql>\r\n</request>\r\n";
62 //write request
63 fputs($fToOpen, $sSend);
64 //now read response
65 while (!feof($fToOpen))
67 $sReturn = $sReturn . fgets($fToOpen, 128);
69 fclose($fToOpen);
71 return $sReturn;
73 }//class