mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Merged from McMasterReports branch
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
|
||||
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
@@ -70,7 +70,8 @@ class ADODB_ado extends ADOConnection {
|
||||
} else {
|
||||
$argDatabasename = '';
|
||||
if ($argDBorProvider) $argProvider = $argDBorProvider;
|
||||
else $argProvider = 'MSDASQL';
|
||||
else if (stripos($argHostname,'PROVIDER') === false) /* full conn string is not in $argHostname */
|
||||
$argProvider = 'MSDASQL';
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +102,9 @@ class ADODB_ado extends ADOConnection {
|
||||
|
||||
if ($argProvider) $dbc->Provider = $argProvider;
|
||||
|
||||
if ($argProvider) $argHostname = "PROVIDER=$argProvider;DRIVER={SQL Server};SERVER=$argHostname";
|
||||
|
||||
|
||||
if ($argDatabasename) $argHostname .= ";DATABASE=$argDatabasename";
|
||||
if ($argUsername) $argHostname .= ";$u=$argUsername";
|
||||
if ($argPassword)$argHostname .= ";$p=$argPassword";
|
||||
@@ -114,6 +118,7 @@ class ADODB_ado extends ADOConnection {
|
||||
$dbc->CursorLocation = $this->_cursor_location;
|
||||
return $dbc->State > 0;
|
||||
} catch (exception $e) {
|
||||
if ($this->debug);echo "<pre>",$argHostname,"\n",$e,"</pre>\n";
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -167,7 +172,7 @@ class ADODB_ado extends ADOConnection {
|
||||
|
||||
*/
|
||||
|
||||
function &MetaTables()
|
||||
function MetaTables()
|
||||
{
|
||||
$arr= array();
|
||||
$dbc = $this->_connectionID;
|
||||
@@ -189,7 +194,7 @@ class ADODB_ado extends ADOConnection {
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function &MetaColumns($table)
|
||||
function MetaColumns($table)
|
||||
{
|
||||
$table = strtoupper($table);
|
||||
$arr= array();
|
||||
@@ -221,7 +226,7 @@ class ADODB_ado extends ADOConnection {
|
||||
}
|
||||
|
||||
/* returns queryID or false */
|
||||
function &_query($sql,$inputarr=false)
|
||||
function _query($sql,$inputarr=false)
|
||||
{
|
||||
try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour...
|
||||
|
||||
@@ -241,13 +246,28 @@ class ADODB_ado extends ADOConnection {
|
||||
$oCmd->CommandText = $sql;
|
||||
$oCmd->CommandType = 1;
|
||||
|
||||
foreach($inputarr as $val) {
|
||||
while(list(, $val) = each($inputarr)) {
|
||||
$type = gettype($val);
|
||||
$len=strlen($val);
|
||||
if ($type == 'boolean')
|
||||
$this->adoParameterType = 11;
|
||||
else if ($type == 'integer')
|
||||
$this->adoParameterType = 3;
|
||||
else if ($type == 'double')
|
||||
$this->adoParameterType = 5;
|
||||
elseif ($type == 'string')
|
||||
$this->adoParameterType = 202;
|
||||
else if (($val === null) || (!defined($val)))
|
||||
$len=1;
|
||||
else
|
||||
$this->adoParameterType = 130;
|
||||
|
||||
// name, type, direction 1 = input, len,
|
||||
$this->adoParameterType = 130;
|
||||
$p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val);
|
||||
//print $p->Type.' '.$p->value;
|
||||
$p = $oCmd->CreateParameter('name',$this->adoParameterType,1,$len,$val);
|
||||
|
||||
$oCmd->Parameters->Append($p);
|
||||
}
|
||||
|
||||
$p = false;
|
||||
$rs = $oCmd->Execute();
|
||||
$e = $dbc->Errors;
|
||||
@@ -367,11 +387,13 @@ class ADORecordSet_ado extends ADORecordSet {
|
||||
|
||||
|
||||
// returns the field object
|
||||
function &FetchField($fieldOffset = -1) {
|
||||
function FetchField($fieldOffset = -1) {
|
||||
$off=$fieldOffset+1; // offsets begin at 1
|
||||
|
||||
$o= new ADOFieldObject();
|
||||
$rs = $this->_queryID;
|
||||
if (!$rs) return false;
|
||||
|
||||
$f = $rs->Fields($fieldOffset);
|
||||
$o->name = $f->Name;
|
||||
$t = $f->Type;
|
||||
@@ -403,8 +425,12 @@ class ADORecordSet_ado extends ADORecordSet {
|
||||
function _initrs()
|
||||
{
|
||||
$rs = $this->_queryID;
|
||||
$this->_numOfRows = $rs->RecordCount;
|
||||
|
||||
try {
|
||||
$this->_numOfRows = $rs->RecordCount;
|
||||
} catch (Exception $e) {
|
||||
$this->_numOfRows = -1;
|
||||
}
|
||||
$f = $rs->Fields;
|
||||
$this->_numOfFields = $f->Count;
|
||||
}
|
||||
@@ -618,6 +644,16 @@ class ADORecordSet_ado extends ADORecordSet {
|
||||
ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>');
|
||||
$this->fields[] = (float) $f->value;
|
||||
break;
|
||||
case 11: //BIT;
|
||||
$val = "";
|
||||
if(is_bool($f->value)) {
|
||||
if($f->value==true) $val = 1;
|
||||
else $val = 0;
|
||||
}
|
||||
if(is_null($f->value)) $val = null;
|
||||
|
||||
$this->fields[] = $val;
|
||||
break;
|
||||
default:
|
||||
$this->fields[] = $f->value;
|
||||
break;
|
||||
@@ -630,7 +666,7 @@ class ADORecordSet_ado extends ADORecordSet {
|
||||
@$rs->MoveNext(); // @ needed for some versions of PHP!
|
||||
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -656,7 +692,10 @@ class ADORecordSet_ado extends ADORecordSet {
|
||||
|
||||
function _close() {
|
||||
$this->_flds = false;
|
||||
try {
|
||||
@$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk)
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
$this->_queryID = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user