18 if (!defined(
'ADODB_DIR'))
die();
54 case 2:
return 'VARCHAR';
55 case 3:
return 'BLOB';
56 default:
return 'NUMERIC';
96 $this->fmtDate = $d->fmtDate;
97 $this->fmtTimeStamp = $d->fmtTimeStamp;
98 $this->replaceQuote = $d->replaceQuote;
99 $this->sysDate = $d->sysDate;
100 $this->sysTimeStamp = $d->sysTimeStamp;
101 $this->random = $d->random;
102 $this->concat_operator = $d->concat_operator;
103 $this->nameQuote = $d->nameQuote;
105 $this->hasGenID = $d->hasGenID;
106 $this->_genIDSQL = $d->_genIDSQL;
107 $this->_genSeqSQL = $d->_genSeqSQL;
108 $this->_dropSeqSQL = $d->_dropSeqSQL;
115 if (!empty($this->_driver->_hasdual))
$sql =
"select $this->sysTimeStamp from dual";
116 else $sql =
"select $this->sysTimeStamp";
119 if (
$rs && !
$rs->EOF)
return $this->UnixTimeStamp(reset(
$rs->fields));
125 function _connect($argDSN, $argUsername, $argPassword, $argDatabasename, $persist=
false)
127 $at = strpos($argDSN,
':');
128 $this->dsnType = substr($argDSN,0,$at);
130 if ($argDatabasename) {
131 $argDSN .=
';dbname='.$argDatabasename;
134 $this->_connectionID =
new PDO($argDSN, $argUsername, $argPassword);
135 }
catch (Exception $e) {
136 $this->_connectionID =
false;
137 $this->_errorno = -1;
139 $this->_errormsg =
'Connection attempt failed: '.$e->getMessage();
143 if ($this->_connectionID) {
144 switch(ADODB_ASSOC_CASE){
145 case 0: $m = PDO::CASE_LOWER;
break;
146 case 1: $m = PDO::CASE_UPPER;
break;
148 case 2: $m = PDO::CASE_NATURAL;
break;
152 $this->_connectionID->setAttribute(PDO::ATTR_CASE,$m);
154 $class =
'ADODB_pdo_'.$this->dsnType;
156 switch($this->dsnType) {
162 include_once(ADODB_DIR.
'/drivers/adodb-pdo_'.$this->dsnType.
'.inc.php');
165 if (class_exists($class))
166 $this->_driver =
new $class();
170 $this->_driver->_connectionID = $this->_connectionID;
180 $args = func_get_args();
181 if(method_exists($this->_driver,
'Concat'))
182 return call_user_func_array(array($this->_driver,
'Concat'), $args);
184 if (PHP_VERSION >= 5.3)
return call_user_func_array(
'parent::Concat', $args);
185 return call_user_func_array(array($this,
'parent::Concat'), $args);
189 function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
191 return $this->
_connect($argDSN, $argUsername, $argPassword, $argDatabasename,
true);
199 $save = $this->_driver->fetchMode;
200 $this->_driver->fetchMode = $this->fetchMode;
201 $this->_driver->debug = $this->debug;
202 $ret = $this->_driver->SelectLimit(
$sql,$nrows,$offset,$inputarr,$secs2cache);
203 $this->_driver->fetchMode = $save;
210 return $this->_driver->ServerInfo();
213 function MetaTables($ttype=
false,$showSchema=
false,$mask=
false)
215 return $this->_driver->MetaTables($ttype,$showSchema,$mask);
220 return $this->_driver->MetaColumns($table,$normalize);
226 if ($type) $obj->bindParam($name,$var,$type,$maxLen);
227 else $obj->bindParam($name, $var);
232 return $this->_driver->OffsetDate($dayFraction,$date);
238 if (!empty($this->_stmt)) $arr = $this->_stmt->errorInfo();
239 else if (!empty($this->_connectionID)) $arr = $this->_connectionID->errorInfo();
240 else return 'No Connection Established';
244 if (
sizeof($arr)<2)
return '';
245 if ((integer)$arr[0])
return $arr[2];
254 if (!empty($this->_stmt)) $err = $this->_stmt->errorCode();
255 else if (!empty($this->_connectionID)) {
256 $arr = $this->_connectionID->errorInfo();
257 if (isset($arr[0])) $err = $arr[0];
262 if ($err ==
'00000')
return 0;
268 if(method_exists($this->_driver,
'SetTransactionMode'))
269 return $this->_driver->SetTransactionMode($transaction_mode);
271 return parent::SetTransactionMode($seqname);
276 if(method_exists($this->_driver,
'BeginTrans'))
277 return $this->_driver->BeginTrans();
279 if (!$this->hasTransactions)
return false;
280 if ($this->transOff)
return true;
281 $this->transCnt += 1;
282 $this->_autocommit =
false;
283 $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,
false);
284 return $this->_connectionID->beginTransaction();
289 if(method_exists($this->_driver,
'CommitTrans'))
290 return $this->_driver->CommitTrans($ok);
292 if (!$this->hasTransactions)
return false;
293 if ($this->transOff)
return true;
295 if ($this->transCnt) $this->transCnt -= 1;
296 $this->_autocommit =
true;
298 $ret = $this->_connectionID->commit();
299 $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,
true);
305 if(method_exists($this->_driver,
'RollbackTrans'))
306 return $this->_driver->RollbackTrans();
308 if (!$this->hasTransactions)
return false;
309 if ($this->transOff)
return true;
310 if ($this->transCnt) $this->transCnt -= 1;
311 $this->_autocommit =
true;
313 $ret = $this->_connectionID->rollback();
314 $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,
true);
320 $this->_stmt = $this->_connectionID->prepare(
$sql);
321 if ($this->_stmt)
return array(
$sql,$this->_stmt);
328 $stmt = $this->_connectionID->prepare(
$sql);
329 if (!$stmt)
return false;
336 if(method_exists($this->_driver,
'CreateSequence'))
337 return $this->_driver->CreateSequence($seqname, $startID);
339 return parent::CreateSequence($seqname, $startID);
344 if(method_exists($this->_driver,
'DropSequence'))
345 return $this->_driver->DropSequence($seqname);
347 return parent::DropSequence($seqname);
350 function GenID($seqname=
'adodbseq',$startID=1)
352 if(method_exists($this->_driver,
'GenID'))
353 return $this->_driver->GenID($seqname, $startID);
355 return parent::GenID($seqname, $startID);
362 if (is_array(
$sql)) {
365 $stmt = $this->_connectionID->prepare(
$sql);
368 #var_dump($this->_bindInputArray); 370 $this->_driver->debug = $this->debug;
371 if ($inputarr) $ok = $stmt->execute($inputarr);
372 else $ok = $stmt->execute();
376 $this->_errormsg =
false;
377 $this->_errorno =
false;
380 $this->_stmt =
$stmt;
386 $arr = $stmt->errorinfo();
387 if ((integer)$arr[1]) {
388 $this->_errormsg = $arr[2];
389 $this->_errorno = $arr[1];
393 $this->_errormsg =
false;
394 $this->_errorno =
false;
402 $this->_stmt =
false;
408 return ($this->_stmt) ? $this->_stmt->rowCount() : 0;
413 return ($this->_connectionID) ? $this->_connectionID->lastInsertId() : 0;
419 var $sysDate =
"'?'";
420 var $sysTimeStamp =
"'?'";
425 $parentDriver->_bindInputArray =
true;
426 #$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); 431 return ADOConnection::ServerInfo();
436 $ret = ADOConnection::SelectLimit(
$sql,$nrows,$offset,$inputarr,$secs2cache);
460 $this->_stmt =
$stmt;
461 $this->_connectionID = $connection;
466 $savestmt = $this->_connectionID->_stmt;
467 $rs = $this->_connectionID->Execute(array(
false,$this->_stmt),$inputArr);
468 $this->_connectionID->_stmt = $savestmt;
475 if ($type) $this->_stmt->bindParam($name,$var,$type,$maxLen);
476 else $this->_stmt->bindParam($name, $var);
481 return ($this->_stmt) ? $this->_stmt->rowCount() : 0;
486 if ($this->_stmt) $arr = $this->_stmt->errorInfo();
487 else $arr = $this->_connectionID->errorInfo();
489 if (is_array($arr)) {
490 if ((integer) $arr[0] && isset($arr[2]))
return $arr[2];
497 return ($this->_stmt) ? $this->_stmt->columnCount() : 0;
502 if ($this->_stmt)
return $this->_stmt->errorCode();
503 else return $this->_connectionID->errorInfo();
519 if ($mode ===
false) {
520 global $ADODB_FETCH_MODE;
521 $mode = $ADODB_FETCH_MODE;
523 $this->adodbFetchMode = $mode;
525 case ADODB_FETCH_NUM: $mode = PDO::FETCH_NUM;
break;
526 case ADODB_FETCH_ASSOC: $mode = PDO::FETCH_ASSOC;
break;
528 case ADODB_FETCH_BOTH:
529 default: $mode = PDO::FETCH_BOTH;
break;
531 $this->fetchMode = $mode;
533 $this->_queryID = $id;
534 $this->ADORecordSet($id);
540 if ($this->_inited)
return;
541 $this->_inited =
true;
542 if ($this->_queryID) @$this->_initrs();
544 $this->_numOfRows = 0;
545 $this->_numOfFields = 0;
547 if ($this->_numOfRows != 0 && $this->_currentRow == -1) {
548 $this->_currentRow = 0;
549 if ($this->EOF = ($this->_fetch() ===
false)) {
550 $this->_numOfRows = 0;
559 global $ADODB_COUNTRECS;
561 $this->_numOfRows = ($ADODB_COUNTRECS) ? @$this->_queryID->rowCount() : -1;
562 if (!$this->_numOfRows) $this->_numOfRows = -1;
563 $this->_numOfFields = $this->_queryID->columnCount();
571 $o=
new ADOFieldObject();
572 $arr = @$this->_queryID->getColumnMeta($fieldOffset);
574 $o->name =
'bad getColumnMeta()';
576 $o->type =
'VARCHAR';
582 $o->name = $arr[
'name'];
583 if (isset($arr[
'native_type']) && $arr[
'native_type'] <>
"null") $o->type = $arr[
'native_type'];
585 $o->max_length = $arr[
'len'];
586 $o->precision = $arr[
'precision'];
588 if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
589 else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
600 if (!$this->_queryID)
return false;
602 $this->fields = $this->_queryID->fetch($this->fetchMode);
603 return !empty($this->fields);
608 $this->_queryID =
false;
613 if ($this->adodbFetchMode != ADODB_FETCH_NUM)
return @$this->fields[$colname];
616 $this->bind = array();
617 for ($i=0; $i < $this->_numOfFields; $i++) {
618 $o = $this->FetchField($i);
619 $this->bind[strtoupper($o->name)] = $i;
622 return $this->fields[$this->bind[strtoupper($colname)]];
InParameter(&$var, $name, $maxLen=4000, $type=false)
SetTransactionMode($transaction_mode)
DropSequence($seqname='adodbseq')
MetaColumns($table, $normalize=true)
if(isset($_REQUEST['nrows'])) else $rs
MetaTables($ttype=false, $showSchema=false, $mask=false)
ADOPDOStatement($stmt, $connection)
_query($sql, $inputarr=false)
GenID($seqname='adodbseq', $startID=1)
InParameter(&$stmt, &$var, $name, $maxLen=4000, $type=false)
SelectLimit($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs2cache=0)
ADORecordSet_pdo($id, $mode=false)
OffsetDate($dayFraction, $date=false)
FetchField($fieldOffset=-1)
SelectLimit($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs2cache=0)
CreateSequence($seqname='adodbseq', $startID=1)
_pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
_connect($argDSN, $argUsername, $argPassword, $argDatabasename, $persist=false)