Source for file adodb-pdo.inc.php
Documentation is available at adodb-pdo.inc.php
V4.97 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). 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.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Requires ODBC. Works on Windows and Unix.
Where is float/decimal type in pdo_param_type
LOB handling for CLOB/BLOB differs significantly
/* int as in long (the php native int type).
* If you mark a column as an int, PDO expects get_col to return
/* get_col ptr should point to start of the string buffer
/* get_col: when len is 0 ptr should point to a php_stream *,
* otherwise it should behave like a string. Indicate a NULL field
* value by setting the ptr to NULL
/* get_col: will expect the ptr to point to a new PDOStatement object handle,
* but this isn't wired up yet
PDO::PARAM_STMT, 4 /* hierarchical result set
/* get_col ptr should point to a zend_bool
/* magic flag to denote a parameter as being input/output
PDO::PARAM_INPUT_OUTPUT = 0x80000000
case 2: return 'VARCHAR';
default: return 'NUMERIC';
/*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/
////////////////////////////////////////////////
$this->_genIDSQL = $d->_genIDSQL;
$this->_dropSeqSQL = $d->_dropSeqSQL;
if (!empty($this->_driver->_hasdual)) $sql = "select $this->sysTimeStamp from dual";
function _connect($argDSN, $argUsername, $argPassword, $argDatabasename, $persist= false)
$argDSN .= ';dbname='. $argDatabasename;
$this->_connectionID = new PDO($argDSN, $argUsername, $argPassword);
$this->_errormsg = 'Connection attempt failed: '. $e->getMessage();
switch(ADODB_ASSOC_CASE){
case 0: $m = PDO::CASE_LOWER; break;
case 1: $m = PDO::CASE_UPPER; break;
case 2: $m = PDO::CASE_NATURAL; break;
//$this->_connectionID->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_SILENT );
$class = 'ADODB_pdo_'. $this->dsnType;
//$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true);
$this->_driver = new $class();
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 $this->_driver->ServerInfo();
function MetaTables($ttype= false,$showSchema= false,$mask= false)
return $this->_driver->MetaTables($ttype,$showSchema,$mask);
return $this->_driver->MetaColumns($table,$normalize);
function InParameter(&$stmt,&$var,$name,$maxLen= 4000,$type= false)
if ($type) $obj->bindParam($name,$var,$type,$maxLen);
else $obj->bindParam($name, $var);
if (!empty($this->_stmt)) $arr = $this->_stmt->errorInfo();
else return 'No Connection Established';
if (sizeof($arr)< 2) return '';
if ((integer) $arr[1]) return $arr[2];
if (!empty($this->_stmt)) $err = $this->_stmt->errorCode();
if (isset ($arr[0])) $err = $arr[0];
if ($err == '00000') return 0; // allows empty check
if ($this->_stmt) return array($sql,$this->_stmt);
if (!$stmt) return false;
/* returns queryID or false */
function _query($sql,$inputarr= false)
#var_dump($this->_bindInputArray);
$this->_driver->debug = $this->debug;
if ($inputarr) $ok = $stmt->execute($inputarr);
else $ok = $stmt->execute();
$arr = $stmt->errorinfo();
return ($this->_stmt) ? $this->_stmt->rowCount() : 0;
function _init($parentDriver)
$parentDriver->_bindInputArray = true;
#$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
function SelectLimit($sql,$nrows=- 1,$offset=- 1,$inputarr= false,$secs2cache= 0)
function InParameter(&$var,$name,$maxLen= 4000,$type= false)
if ($type) $this->_stmt->bindParam($name,$var,$type,$maxLen);
else $this->_stmt->bindParam($name, $var);
return ($this->_stmt) ? $this->_stmt->rowCount() : 0;
if ($this->_stmt) $arr = $this->_stmt->errorInfo();
if ((integer) $arr[0] && isset ($arr[2])) return $arr[2];
return ($this->_stmt) ? $this->_stmt->columnCount() : 0;
if ($this->_stmt) return $this->_stmt->errorCode();
/*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
$this->adodbFetchMode = $mode;
default: $mode = PDO::FETCH_BOTH; break;
if ($this->EOF = ($this->_fetch() === false)) {
// returns the field object
$off= $fieldOffset+ 1; // offsets begin at 1
$arr = @$this->_queryID->getColumnMeta($fieldOffset);
$o->name = 'bad getColumnMeta()';
if (isset ($arr['native_type']) && $arr['native_type'] <> "null") $o->type = $arr['native_type'];
$o->max_length = $arr['len'];
$o->precision = $arr['precision'];
if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
|