00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 if (!defined('ADODB_DIR')) die();
00046
00047 if (!defined('_ADODB_ODBC_LAYER')) {
00048 include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
00049 }
00050
00051 if (!defined('ADODB_SYBASE_SQLANYWHERE')){
00052
00053 define('ADODB_SYBASE_SQLANYWHERE',1);
00054
00055 class ADODB_sqlanywhere extends ADODB_odbc {
00056 var $databaseType = "sqlanywhere";
00057 var $hasInsertID = true;
00058
00059 function ADODB_sqlanywhere()
00060 {
00061 $this->ADODB_odbc();
00062 }
00063
00064 function _insertid() {
00065 return $this->GetOne('select @@identity');
00066 }
00067
00068 function create_blobvar($blobVarName) {
00069 $this->Execute("create variable $blobVarName long binary");
00070 return;
00071 }
00072
00073 function drop_blobvar($blobVarName) {
00074 $this->Execute("drop variable $blobVarName");
00075 return;
00076 }
00077
00078 function load_blobvar_from_file($blobVarName, $filename) {
00079 $chunk_size = 1000;
00080
00081 $fd = fopen ($filename, "rb");
00082
00083 $integer_chunks = (integer)filesize($filename) / $chunk_size;
00084 $modulus = filesize($filename) % $chunk_size;
00085 if ($modulus != 0){
00086 $integer_chunks += 1;
00087 }
00088
00089 for($loop=1;$loop<=$integer_chunks;$loop++){
00090 $contents = fread ($fd, $chunk_size);
00091 $contents = bin2hex($contents);
00092
00093 $hexstring = '';
00094
00095 for($loop2=0;$loop2<strlen($contents);$loop2+=2){
00096 $hexstring .= '\x' . substr($contents,$loop2,2);
00097 }
00098
00099 $hexstring = $this->qstr($hexstring);
00100
00101 $this->Execute("set $blobVarName = $blobVarName || " . $hexstring);
00102 }
00103
00104 fclose ($fd);
00105 return;
00106 }
00107
00108 function load_blobvar_from_var($blobVarName, &$varName) {
00109 $chunk_size = 1000;
00110
00111 $integer_chunks = (integer)strlen($varName) / $chunk_size;
00112 $modulus = strlen($varName) % $chunk_size;
00113 if ($modulus != 0){
00114 $integer_chunks += 1;
00115 }
00116
00117 for($loop=1;$loop<=$integer_chunks;$loop++){
00118 $contents = substr ($varName, (($loop - 1) * $chunk_size), $chunk_size);
00119 $contents = bin2hex($contents);
00120
00121 $hexstring = '';
00122
00123 for($loop2=0;$loop2<strlen($contents);$loop2+=2){
00124 $hexstring .= '\x' . substr($contents,$loop2,2);
00125 }
00126
00127 $hexstring = $this->qstr($hexstring);
00128
00129 $this->Execute("set $blobVarName = $blobVarName || " . $hexstring);
00130 }
00131
00132 return;
00133 }
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 function UpdateBlob($table,$column,&$val,$where,$blobtype='BLOB')
00145 {
00146 $blobVarName = 'hold_blob';
00147 $this->create_blobvar($blobVarName);
00148 $this->load_blobvar_from_var($blobVarName, $val);
00149 $this->Execute("UPDATE $table SET $column=$blobVarName WHERE $where");
00150 $this->drop_blobvar($blobVarName);
00151 return true;
00152 }
00153 };
00154
00155 class ADORecordSet_sqlanywhere extends ADORecordSet_odbc {
00156
00157 var $databaseType = "sqlanywhere";
00158
00159 function ADORecordSet_sqlanywhere($id,$mode=false)
00160 {
00161 $this->ADORecordSet_odbc($id,$mode);
00162 }
00163
00164
00165 };
00166
00167
00168 }
00169 ?>