Merge branch 'MDL-33441' of git://github.com/danpoltawski/moodle
[moodle.git] / lib / adodb / drivers / adodb-vfp.inc.php
blob107ebfcc039cef2f223035361bf76c4305262319
1 <?php
2 /*
3 V5.16 26 Mar 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
4 Released under both BSD license and Lesser GPL library license.
5 Whenever there is any discrepancy between the two licenses,
6 the BSD license will take precedence.
7 Set tabs to 4 for best viewing.
9 Latest version is available at http://adodb.sourceforge.net
11 Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
14 // security - hide paths
15 if (!defined('ADODB_DIR')) die();
17 if (!defined('_ADODB_ODBC_LAYER')) {
18 include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
20 if (!defined('ADODB_VFP')){
21 define('ADODB_VFP',1);
22 class ADODB_vfp extends ADODB_odbc {
23 var $databaseType = "vfp";
24 var $fmtDate = "{^Y-m-d}";
25 var $fmtTimeStamp = "{^Y-m-d, h:i:sA}";
26 var $replaceQuote = "'+chr(39)+'" ;
27 var $true = '.T.';
28 var $false = '.F.';
29 var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
30 var $_bindInputArray = false; // strangely enough, setting to true does not work reliably
31 var $sysTimeStamp = 'datetime()';
32 var $sysDate = 'date()';
33 var $ansiOuter = true;
34 var $hasTransactions = false;
35 var $curmode = false ; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L
37 function ADODB_vfp()
39 $this->ADODB_odbc();
42 function Time()
44 return time();
47 function BeginTrans() { return false;}
49 // quote string to be sent back to database
50 function qstr($s,$nofixquotes=false)
52 if (!$nofixquotes) return "'".str_replace("\r\n","'+chr(13)+'",str_replace("'",$this->replaceQuote,$s))."'";
53 return "'".$s."'";
57 // TOP requires ORDER BY for VFP
58 function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
60 $this->hasTop = preg_match('/ORDER[ \t\r\n]+BY/is',$sql) ? 'top' : false;
61 $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
62 return $ret;
70 class ADORecordSet_vfp extends ADORecordSet_odbc {
72 var $databaseType = "vfp";
75 function ADORecordSet_vfp($id,$mode=false)
77 return $this->ADORecordSet_odbc($id,$mode);
80 function MetaType($t,$len=-1)
82 if (is_object($t)) {
83 $fieldobj = $t;
84 $t = $fieldobj->type;
85 $len = $fieldobj->max_length;
87 switch (strtoupper($t)) {
88 case 'C':
89 if ($len <= $this->blobSize) return 'C';
90 case 'M':
91 return 'X';
93 case 'D': return 'D';
95 case 'T': return 'T';
97 case 'L': return 'L';
99 case 'I': return 'I';
101 default: return 'N';
106 } //define