rname, $argPassword, $argDatabasename, $persist=false)
{
$at = strpos($argDSN,':');
$this->dsnType = substr($argDSN,0,$at);
if ($argDatabasename) {
$argDSN .= ';dbname='.$argDatabasename;
}
try {
$this->_connectionID = new PDO($argDSN, $argUsername, $argPassword);
} catch (Exception $e) {
$this->_connectionID = false;
$this->_errorno = -1;
//var_dump($e);
$this->_errormsg = 'Connection attempt failed: '.$e->getMessage();
return false;
}
if ($this->_connectionID) {
switch(ADODB_ASSOC_CASE){
case 0: $m = PDO::CASE_LOWER; break;
case 1: $m = PDO::CASE_UPPER; break;
default:
case 2: $m = PDO::CASE_NATURAL; break;
}
//$this->_connectionID->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_SILENT );
$this->_connectionID->setAttribute(PDO::ATTR_CASE,$m);
$class = 'ADODB_pdo_'.$this->dsnType;
//$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true);
switch($this->dsnType) {
case 'oci':
case 'mysql':
case 'pgsql':
case 'mssql':
include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php');
break;
}
if (class_exists($class))
$this->_driver = new $class();
else
$this->_driver = new ADODB_pdo_base();
$this->_driver->_connectionID = $this->_connectionID;
$this->_UpdatePDO();
return true;
}
$this->_driver = new ADODB_pdo_base();
return false;
}
// returns true or false
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
return $this->_connect($argDSN, $argUsername, $argPassword, $argDatabasename, true);
}
/*------------------------------------------------------------------------------*/
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
$save = $this->_driver->fetchMode;
$this->_driver->fetchMode = $this->fetchMode;
$this->_driver->debug = $this->debug;
$ret = $this->_driver->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
$this->_driver->fetchMode = $save;
return $ret;
}
function ServerInfo()
{
return $this->_driver->ServerInfo();
}
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
return $this->_driver->MetaTables($ttype,$showSchema,$mask);
}
function MetaColumns($table,$normalize=true)
{
return $this->_driver->MetaColumns($table,$normalize);
}
function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
{
$obj = $stmt[1];
if ($type) $obj->bindParam($name,$var,$type,$maxLen);
else $obj->bindParam($name, $var);
}
function ErrorMsg()
{
if ($this->_errormsg !== false) return $this->_errormsg;
if (!empty($this->_stmt)) $arr = $this->_stmt->errorInfo();
else if (!empty($this->_connectionID)) $arr = $this->_connectionID->errorInfo();
else return 'No Connection Established';
if ($arr) {
if (sizeof($arr)<2) return '';
if ((integer)$arr[1]) return $arr[2];
else return '';
} else return '-1';
}
function ErrorNo()
{
if ($this->_errorno !== false) return $this->_errorno;
if (!empty($this->_stmt)) $err = $this->_stmt->errorCode();
else if (!empty($this->_connectionID)) {
$arr = $this->_connectionID->errorInfo();
if (isset($arr[0])) $err = $arr[0];
else $err = -1;
} else
return 0;
if ($err == '00000') return 0; // allows empty check
return $err;
}
function BeginTrans()
{
if (!$this->hasTransactions) return false;
if ($this->transOff) return true;
$this->transCnt += 1;
$this->_autocommit = false;
$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,false);
return $this->_connectionID->beginTransaction();
}
function CommitTrans($ok=true)
{
if (!$this->hasTransactions) return false;
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
$