function &_query($sql, $inputarr = false) { try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour... $dbc = $this->_connectionID; // return rs if ($inputarr) { if (!empty($this->charPage)) { $oCmd = new COM('ADODB.Command', null, $this->charPage); } else { $oCmd = new COM('ADODB.Command'); } $oCmd->ActiveConnection = $dbc; $oCmd->CommandText = $sql; $oCmd->CommandType = 1; foreach ($inputarr as $val) { // name, type, direction 1 = input, len, $this->adoParameterType = 130; $p = $oCmd->CreateParameter('name', $this->adoParameterType, 1, strlen($val), $val); //print $p->Type.' '.$p->value; $oCmd->Parameters->Append($p); } $p = false; $rs = $oCmd->Execute(); $e = $dbc->Errors; if ($dbc->Errors->Count > 0) { return false; } return $rs; } $rs = @$dbc->Execute($sql, $this->_affectedRows, $this->_execute_option); if ($dbc->Errors->Count > 0) { return false; } if (!$rs) { return false; } if ($rs->State == 0) { return true; } // 0 = adStateClosed means no records returned return $rs; } catch (exception $e) { } return false; }
function _query($sql,$inputarr=false) { try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour... $dbc = $this->_connectionID; // return rs $false = false; if ($inputarr) { if (!empty($this->charPage)) $oCmd = new COM('ADODB.Command',null,$this->charPage); else $oCmd = new COM('ADODB.Command'); $oCmd->ActiveConnection = $dbc; $oCmd->CommandText = $sql; $oCmd->CommandType = 1; 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, $p = $oCmd->CreateParameter('name',$this->adoParameterType,1,$len,$val); $oCmd->Parameters->Append($p); } $p = false; $rs = $oCmd->Execute(); $e = $dbc->Errors; if ($dbc->Errors->Count > 0) return $false; return $rs; } $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option); if ($dbc->Errors->Count > 0) return $false; if (! $rs) return $false; if ($rs->State == 0) { $true = true; return $true; // 0 = adStateClosed means no records returned } return $rs; } catch (exception $e) { } return $false; }
function _query($sql, $inputarr = false) { $dbc = $this->_connectionID; $false = false; // return rs if ($inputarr) { if (!empty($this->charPage)) { $oCmd = new COM('ADODB.Command', null, $this->charPage); } else { $oCmd = new COM('ADODB.Command'); } $oCmd->ActiveConnection = $dbc; $oCmd->CommandText = $sql; $oCmd->CommandType = 1; // Map by http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthcreateparam.asp // Check issue http://bugs.php.net/bug.php?id=40664 !!! 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, $p = $oCmd->CreateParameter('name', $this->adoParameterType, 1, $len, $val); $oCmd->Parameters->Append($p); } $p = false; $rs = $oCmd->Execute(); $e = $dbc->Errors; if ($dbc->Errors->Count > 0) { return $false; } return $rs; } $rs = @$dbc->Execute($sql, $this->_affectedRows, $this->_execute_option); if ($dbc->Errors->Count > 0) { return $false; } if (!$rs) { return $false; } if ($rs->State == 0) { $true = true; return $true; // 0 = adStateClosed means no records returned } return $rs; }
function _query($sql, $inputarr = false) { $dbc = $this->_connectionID; $false = false; if ($inputarr) { if (!empty($this->charPage)) { $oCmd = new COM('ADODB.Command', null, $this->charPage); } else { $oCmd = new COM('ADODB.Command'); } $oCmd->ActiveConnection = $dbc; $oCmd->CommandText = $sql; $oCmd->CommandType = 1; foreach ($inputarr as $val) { $this->adoParameterType = 130; $p = $oCmd->CreateParameter('name', $this->adoParameterType, 1, strlen($val), $val); $oCmd->Parameters->Append($p); } $p = false; $rs = $oCmd->Execute(); $e = $dbc->Errors; if (0 < $dbc->Errors->Count) { return $false; } return $rs; } $rs = @$dbc->Execute($sql, $this->_affectedRows, $this->_execute_option); if (0 < $dbc->Errors->Count) { return $false; } if (!$rs) { return $false; } if ($rs->State == 0) { $true = true; return $true; } return $rs; }
function &_query($sql,$inputarr=false) { $dbc = $this->_connectionID; $false = false; // return rs if ($inputarr) { if (!empty($this->charPage)) $oCmd = new COM('ADODB.Command',null,$this->charPage); else $oCmd = new COM('ADODB.Command'); $oCmd->ActiveConnection = $dbc; $oCmd->CommandText = $sql; $oCmd->CommandType = 1; foreach($inputarr as $val) { // name, type, direction 1 = input, len, $this->adoParameterType = 130; $p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val); //print $p->Type.' '.$p->value; $oCmd->Parameters->Append($p); } $p = false; $rs = $oCmd->Execute(); $e = $dbc->Errors; if ($dbc->Errors->Count > 0) return $false; return $rs; } $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option); if ($dbc->Errors->Count > 0) return $false; if (! $rs) return $false; if ($rs->State == 0) { $true = true; return $true; // 0 = adStateClosed means no records returned } return $rs; }
function &_query($sql, $inputarr = false) { $dbc = $this->_connectionID; // return rs if ($inputarr) { $oCmd = new COM('ADODB.Command'); $oCmd->ActiveConnection = $dbc; $oCmd->CommandText = $sql; $oCmd->CommandType = 1; foreach ($inputarr as $val) { // name, type, direction 1 = input, len, $this->adoParameterType = 130; $p = $oCmd->CreateParameter('name', $this->adoParameterType, 1, strlen($val), $val); //print $p->Type.' '.$p->value; $oCmd->Parameters->Append($p); } $p = false; $rs = $oCmd->Execute(); $e = $dbc->Errors; if ($dbc->Errors->Count > 0) { return false; } return $rs; } $rs = @$dbc->Execute($sql, $this->_affectedRows); if ($dbc->Errors->Count > 0) { return false; } return $rs; }