summaryrefslogtreecommitdiff
path: root/adodb.inc.php
diff options
context:
space:
mode:
authorDamien Regad <dregad@mantisbt.org>2014-09-26 16:45:52 +0200
committerDamien Regad <dregad@mantisbt.org>2014-09-26 16:45:52 +0200
commit016dea3c70a7e2bd146907213f050931a8fbf684 (patch)
treea076d129beab61c1bcf6ad9df2b9d1f9af248116 /adodb.inc.php
parent7d7dd7efe7d83c6cedb6b8c048cdb7dbe24855eb (diff)
downloadadodb-016dea3c70a7e2bd146907213f050931a8fbf684.tar.gz
adodb-016dea3c70a7e2bd146907213f050931a8fbf684.tar.bz2
adodb-016dea3c70a7e2bd146907213f050931a8fbf684.zip
Coding guidelines / whitespace
Diffstat (limited to 'adodb.inc.php')
-rw-r--r--adodb.inc.php2333
1 files changed, 1308 insertions, 1025 deletions
diff --git a/adodb.inc.php b/adodb.inc.php
index 9d4253b3..0dacb91e 100644
--- a/adodb.inc.php
+++ b/adodb.inc.php
@@ -14,7 +14,7 @@
/**
\mainpage
- @version V5.20dev ??-???-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
+ @version V5.20dev ??-???-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license. You can choose which license
you prefer.
@@ -44,21 +44,23 @@ if (!defined('_ADODB_LAYER')) {
* Set ADODB_DIR to the directory where this file resides...
* This constant was formerly called $ADODB_RootPath
*/
- if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__));
+ if (!defined('ADODB_DIR')) {
+ define('ADODB_DIR',dirname(__FILE__));
+ }
//==============================================================================================
// GLOBAL VARIABLES
//==============================================================================================
GLOBAL
- $ADODB_vers, // database version
+ $ADODB_vers, // database version
$ADODB_COUNTRECS, // count number of records returned - slows down query
$ADODB_CACHE_DIR, // directory to cache recordsets
$ADODB_CACHE,
$ADODB_CACHE_CLASS,
$ADODB_EXTENSION, // ADODB extension installed
$ADODB_COMPAT_FETCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF
- $ADODB_FETCH_MODE, // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default...
+ $ADODB_FETCH_MODE, // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default...
$ADODB_GETONE_EOF,
$ADODB_QUOTE_FIELDNAMES; // Allows you to force quotes (backticks) around field names in queries generated by getinsertsql and getupdatesql.
@@ -84,7 +86,7 @@ if (!defined('_ADODB_LAYER')) {
// ********************************************************
- if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) {
+
define('ADODB_BAD_RS','<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>');
@@ -92,7 +94,9 @@ if (!defined('_ADODB_LAYER')) {
define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"\`\.\@\[-]*)');
// prefetching used by oracle
- if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10);
+ if (!defined('ADODB_PREFETCH_ROWS')) {
+ define('ADODB_PREFETCH_ROWS',10);
+ }
/*
@@ -112,7 +116,9 @@ if (!defined('_ADODB_LAYER')) {
define('ADODB_FETCH_ASSOC',2);
define('ADODB_FETCH_BOTH',3);
- if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100);
+ if (!defined('TIMESTAMP_FIRST_YEAR')) {
+ define('TIMESTAMP_FIRST_YEAR',100);
+ }
// PHP's version scheme makes converting to numbers difficult - workaround
$_adodb_ver = (float) PHP_VERSION;
@@ -125,15 +131,18 @@ if (!defined('_ADODB_LAYER')) {
}
- //if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
+ //if (!defined('ADODB_ASSOC_CASE')) {
+ // define('ADODB_ASSOC_CASE',2);
+ //}
/**
- Accepts $src and $dest arrays, replacing string $data
+ Accepts $src and $dest arrays, replacing string $data
*/
- function ADODB_str_replace($src, $dest, $data)
- {
- if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data);
+ function ADODB_str_replace($src, $dest, $data) {
+ if (ADODB_PHPVER >= 0x4050) {
+ return str_replace($src,$dest,$data);
+ }
$s = reset($src);
$d = reset($dest);
@@ -145,20 +154,21 @@ if (!defined('_ADODB_LAYER')) {
return $data;
}
- function ADODB_Setup()
- {
+ function ADODB_Setup() {
GLOBAL
- $ADODB_vers, // database version
+ $ADODB_vers, // database version
$ADODB_COUNTRECS, // count number of records returned - slows down query
$ADODB_CACHE_DIR, // directory to cache recordsets
- $ADODB_FETCH_MODE,
+ $ADODB_FETCH_MODE,
$ADODB_CACHE,
$ADODB_CACHE_CLASS,
$ADODB_FORCE_TYPE,
$ADODB_GETONE_EOF,
$ADODB_QUOTE_FIELDNAMES;
- if (empty($ADODB_CACHE_CLASS)) $ADODB_CACHE_CLASS = 'ADODB_Cache_File' ;
+ if (empty($ADODB_CACHE_CLASS)) {
+ $ADODB_CACHE_CLASS = 'ADODB_Cache_File' ;
+ }
$ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT;
$ADODB_FORCE_TYPE = ADODB_FORCE_VALUE;
$ADODB_GETONE_EOF = null;
@@ -167,14 +177,15 @@ if (!defined('_ADODB_LAYER')) {
$ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? $_ENV['TMP'] : '/tmp';
} else {
// do not accept url based paths, eg. http:/ or ftp:/
- if (strpos($ADODB_CACHE_DIR,'://') !== false)
+ if (strpos($ADODB_CACHE_DIR,'://') !== false) {
die("Illegal path http:// or ftp://");
+ }
}
// Initialize random number generator for randomizing cache flushes
// -- note Since PHP 4.2.0, the seed becomes optional and defaults to a random value if omitted.
- srand(((double)microtime())*1000000);
+ srand(((double)microtime())*1000000);
/**
* ADODB version as a string.
@@ -186,7 +197,9 @@ if (!defined('_ADODB_LAYER')) {
* Set to false for highest performance -- RecordCount() will always return -1 then
* for databases that provide "virtual" recordcounts...
*/
- if (!isset($ADODB_COUNTRECS)) $ADODB_COUNTRECS = true;
+ if (!isset($ADODB_COUNTRECS)) {
+ $ADODB_COUNTRECS = true;
+ }
}
@@ -219,18 +232,19 @@ if (!defined('_ADODB_LAYER')) {
}
- function _adodb_safedate($s)
- {
+ function _adodb_safedate($s) {
return str_replace(array("'", '\\'), '', $s);
}
// parse date string to prevent injection attack
// date string will have one quote at beginning e.g. '3434343'
- function _adodb_safedateq($s)
- {
+ function _adodb_safedateq($s) {
$len = strlen($s);
- if ($s[0] !== "'") $s2 = "'".$s[0];
- else $s2 = "'";
+ if ($s[0] !== "'") {
+ $s2 = "'".$s[0];
+ } else {
+ $s2 = "'";
+ }
for($i=1; $i<$len; $i++) {
$ch = $s[$i];
if ($ch === '\\') {
@@ -250,8 +264,7 @@ if (!defined('_ADODB_LAYER')) {
// for transaction handling
- function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
- {
+ function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) {
//print "Errorno ($fn errno=$errno m=$errmsg) ";
$thisConnection->_transOK = false;
if ($thisConnection->_oldRaiseFn) {
@@ -266,63 +279,68 @@ if (!defined('_ADODB_LAYER')) {
var $createdir = true; // requires creation of temp dirs
- function ADODB_Cache_File()
- {
+ function ADODB_Cache_File() {
global $ADODB_INCLUDED_CSV;
- if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
+ if (empty($ADODB_INCLUDED_CSV)) {
+ include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
+ }
}
// write serialised recordset to cache item/file
- function writecache($filename, $contents, $debug, $secs2cache)
- {
+ function writecache($filename, $contents, $debug, $secs2cache) {
return adodb_write_file($filename, $contents,$debug);
}
// load serialised recordset and unserialise it
- function &readcache($filename, &$err, $secs2cache, $rsClass)
- {
+ function &readcache($filename, &$err, $secs2cache, $rsClass) {
$rs = csv2rs($filename,$err,$secs2cache,$rsClass);
return $rs;
}
// flush all items in cache
- function flushall($debug=false)
- {
+ function flushall($debug=false) {
global $ADODB_CACHE_DIR;
$rez = false;
if (strlen($ADODB_CACHE_DIR) > 1) {
$rez = $this->_dirFlush($ADODB_CACHE_DIR);
- if ($debug) ADOConnection::outp( "flushall: $ADODB_CACHE_DIR<br><pre>\n". $rez."</pre>");
+ if ($debug) {
+ ADOConnection::outp( "flushall: $ADODB_CACHE_DIR<br><pre>\n". $rez."</pre>");
+ }
}
return $rez;
}
// flush one file in cache
- function flushcache($f, $debug=false)
- {
+ function flushcache($f, $debug=false) {
if (!@unlink($f)) {
- if ($debug) ADOConnection::outp( "flushcache: failed for $f");
+ if ($debug) {
+ ADOConnection::outp( "flushcache: failed for $f");
+ }
}
}
- function getdirname($hash)
- {
+ function getdirname($hash) {
global $ADODB_CACHE_DIR;
- if (!isset($this->notSafeMode)) $this->notSafeMode = !ini_get('safe_mode');
+ if (!isset($this->notSafeMode)) {
+ $this->notSafeMode = !ini_get('safe_mode');
+ }
return ($this->notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($hash,0,2) : $ADODB_CACHE_DIR;
}
// create temp directories
- function createdir($hash, $debug)
- {
+ function createdir($hash, $debug) {
global $ADODB_CACHE_PERMS;
$dir = $this->getdirname($hash);
if ($this->notSafeMode && !file_exists($dir)) {
$oldu = umask(0);
- if (!@mkdir($dir, empty($ADODB_CACHE_PERMS) ? 0771 : $ADODB_CACHE_PERMS)) if(!is_dir($dir) && $debug) ADOConnection::outp("Cannot create $dir");
+ if (!@mkdir($dir, empty($ADODB_CACHE_PERMS) ? 0771 : $ADODB_CACHE_PERMS)) {
+ if(!is_dir($dir) && $debug) {
+ ADOConnection::outp("Cannot create $dir");
+ }
+ }
umask($oldu);
}
@@ -335,19 +353,24 @@ if (!defined('_ADODB_LAYER')) {
* Just specify the directory, and tell it if you want to delete the directory or just clear it out.
* Note: $kill_top_level is used internally in the function to flush subdirectories.
*/
- function _dirFlush($dir, $kill_top_level = false)
- {
- if(!$dh = @opendir($dir)) return;
+ function _dirFlush($dir, $kill_top_level = false) {
+ if(!$dh = @opendir($dir)) return;
- while (($obj = readdir($dh))) {
- if($obj=='.' || $obj=='..') continue;
+ while (($obj = readdir($dh))) {
+ if($obj=='.' || $obj=='..') continue;
$f = $dir.'/'.$obj;
- if (strpos($obj,'.cache')) @unlink($f);
- if (is_dir($f)) $this->_dirFlush($f, true);
- }
- if ($kill_top_level === true) @rmdir($dir);
- return true;
+ if (strpos($obj,'.cache')) {
+ @unlink($f);
+ }
+ if (is_dir($f)) {
+ $this->_dirFlush($f, true);
+ }
+ }
+ if ($kill_top_level === true) {
+ @rmdir($dir);
+ }
+ return true;
}
}
@@ -365,11 +388,11 @@ if (!defined('_ADODB_LAYER')) {
var $dataProvider = 'native';
var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql
var $database = ''; /// Name of database to be used.
- var $host = ''; /// The hostname of the database server
- var $user = ''; /// The username which is used to connect to the database server.
- var $password = ''; /// Password for the username. For security, we no longer store it.
- var $debug = false; /// if set to true will output sql statements
- var $maxblobsize = 262144; /// maximum size of blobs or large text fields (262144 = 256K)-- some db's die otherwise like foxpro
+ var $host = ''; /// The hostname of the database server
+ var $user = ''; /// The username which is used to connect to the database server.
+ var $password = ''; /// Password for the username. For security, we no longer store it.
+ var $debug = false; /// if set to true will output sql statements
+ var $maxblobsize = 262144; /// maximum size of blobs or large text fields (262144 = 256K)-- some db's die otherwise like foxpro
var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase
var $substr = 'substr'; /// substring operator
var $length = 'length'; /// string length ofperator
@@ -377,11 +400,11 @@ if (!defined('_ADODB_LAYER')) {
var $upperCase = 'upper'; /// uppercase function
var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database
var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt.
- var $true = '1'; /// string that represents TRUE for a database
- var $false = '0'; /// string that represents FALSE for a database
- var $replaceQuote = "\\'"; /// string to use to replace quotes
+ var $true = '1'; /// string that represents TRUE for a database
+ var $false = '0'; /// string that represents FALSE for a database
+ var $replaceQuote = "\\'"; /// string to use to replace quotes
var $nameQuote = '"'; /// string to use to quote identifiers and names
- var $charSet=false; /// character set to use - only for interbase, postgres and oci8
+ var $charSet=false; /// character set to use - only for interbase, postgres and oci8
var $metaDatabasesSQL = '';
var $metaTablesSQL = '';
var $uniqueOrderBy = false; /// All order by columns have to be unique
@@ -389,19 +412,19 @@ if (!defined('_ADODB_LAYER')) {
var $emptyTimeStamp = '&nbsp;';
var $lastInsID = false;
//--
- var $hasInsertID = false; /// supports autoincrement ID?
- var $hasAffectedRows = false; /// supports affected rows for update/delete?
+ var $hasInsertID = false; /// supports autoincrement ID?
+ var $hasAffectedRows = false; /// supports affected rows for update/delete?
var $hasTop = false; /// support mssql/access SELECT TOP 10 * FROM TABLE
var $hasLimit = false; /// support pgsql/mysql SELECT * FROM TABLE LIMIT 10
- var $readOnly = false; /// this is a readonly database - used by phpLens
- var $hasMoveFirst = false; /// has ability to run MoveFirst(), scrolling backwards
- var $hasGenID = false; /// can generate sequences using GenID();
- var $hasTransactions = true; /// has transactions
+ var $readOnly = false; /// this is a readonly database - used by phpLens
+ var $hasMoveFirst = false; /// has ability to run MoveFirst(), scrolling backwards
+ var $hasGenID = false; /// can generate sequences using GenID();
+ var $hasTransactions = true; /// has transactions
//--
- var $genID = 0; /// sequence id used by GenID();
- var $raiseErrorFn = false; /// error function to call
- var $isoDates = false; /// accepts dates in ISO format
- var $cacheSecs = 3600; /// cache for 1 hour
+ var $genID = 0; /// sequence id used by GenID();
+ var $raiseErrorFn = false; /// error function to call
+ var $isoDates = false; /// accepts dates in ISO format
+ var $cacheSecs = 3600; /// cache for 1 hour
// memcache
var $memCache = false; /// should we use memCache instead of caching in files
@@ -430,17 +453,17 @@ if (!defined('_ADODB_LAYER')) {
var $blobEncodeType = false; // false=not required, 'I'=encode to integer, 'C'=encode to char
var $rsPrefix = "ADORecordSet_";
- var $autoCommit = true; /// do not modify this yourself - actually private
- var $transOff = 0; /// temporarily disable transactions
- var $transCnt = 0; /// count of nested transactions
+ var $autoCommit = true; /// do not modify this yourself - actually private
+ var $transOff = 0; /// temporarily disable transactions
+ var $transCnt = 0; /// count of nested transactions
var $fetchMode=false;
var $null2null = 'null'; // in autoexecute/getinsertsql/getupdatesql, this value will be converted to a null
var $bulkBind = false; // enable 2D Execute array
- //
- // PRIVATE VARS
- //
+ //
+ // PRIVATE VARS
+ //
var $_oldRaiseFn = false;
var $_transOK = null;
var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made.
@@ -457,13 +480,15 @@ if (!defined('_ADODB_LAYER')) {
var $_transmode = ''; // transaction mode
- static function Version()
- {
+ static function Version() {
global $ADODB_vers;
$ok = preg_match( '/^[Vv]?([0-9]\.[0-9]+(dev|[a-z])?)/', $ADODB_vers, $matches );
- if (!$ok) return (float) substr($ADODB_vers,1);
- else return $matches[1];
+ if (!$ok) {
+ return (float) substr($ADODB_vers,1);
+ } else {
+ return $matches[1];
+ }
}
/**
@@ -472,28 +497,27 @@ if (!defined('_ADODB_LAYER')) {
@returns An array with 2 elements: $arr['string'] is the description string,
and $arr[version] is the version (also a string).
*/
- function ServerInfo()
- {
+ function ServerInfo() {
return array('description' => '', 'version' => '');
}
- function IsConnected()
- {
+ function IsConnected() {
return !empty($this->_connectionID);
}
- function _findvers($str)
- {
- if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1];
- else return '';
+ function _findvers($str) {
+ if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) {
+ return $arr[1];
+ } else {
+ return '';
+ }
}
/**
* All error messages go through this bottleneck function.
* You can define your own handler by defining the function name in ADODB_OUTP.
*/
- static function outp($msg,$newline=true)
- {
+ static function outp($msg,$newline=true) {
global $ADODB_FLUSH,$ADODB_OUTP;
if (defined('ADODB_OUTP')) {
@@ -506,20 +530,28 @@ if (!defined('_ADODB_LAYER')) {
return;
}
- if ($newline) $msg .= "<br>\n";
+ if ($newline) {
+ $msg .= "<br>\n";
+ }
- if (isset($_SERVER['HTTP_USER_AGENT']) || !$newline) echo $msg;
- else echo strip_tags($msg);
+ if (isset($_SERVER['HTTP_USER_AGENT']) || !$newline) {
+ echo $msg;
+ } else {
+ echo strip_tags($msg);
+ }
- if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan
+ if (!empty($ADODB_FLUSH) && ob_get_length() !== false) {
+ flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan
+ }
}
- function Time()
- {
+ function Time() {
$rs = $this->_Execute("select $this->sysTimeStamp");
- if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
+ if ($rs && !$rs->EOF) {
+ return $this->UnixTimeStamp(reset($rs->fields));
+ }
return false;
}
@@ -535,39 +567,53 @@ if (!defined('_ADODB_LAYER')) {
*
* @return true or false
*/
- function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false)
- {
- if ($argHostname != "") $this->host = $argHostname;
- if ($argUsername != "") $this->user = $argUsername;
- if ($argPassword != "") $this->password = 'not stored'; // not stored for security reasons
- if ($argDatabaseName != "") $this->database = $argDatabaseName;
+ function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false) {
+ if ($argHostname != "") {
+ $this->host = $argHostname;
+ }
+ if ($argUsername != "") {
+ $this->user = $argUsername;
+ }
+ if ($argPassword != "") {
+ $this->password = 'not stored'; // not stored for security reasons
+ }
+ if ($argDatabaseName != "") {
+ $this->database = $argDatabaseName;
+ }
$this->_isPersistentConnection = false;
if ($forceNew) {
- if ($rez=$this->_nconnect($this->host, $this->user, $argPassword, $this->database)) return true;
+ if ($rez=$this->_nconnect($this->host, $this->user, $argPassword, $this->database)) {
+ return true;
+ }
} else {
- if ($rez=$this->_connect($this->host, $this->user, $argPassword, $this->database)) return true;
+ if ($rez=$this->_connect($this->host, $this->user, $argPassword, $this->database)) {
+ return true;
+ }
}
if (isset($rez)) {
$err = $this->ErrorMsg();
- if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'";
+ if (empty($err)) {
+ $err = "Connection error to server '$argHostname' with user '$argUsername'";
+ }
$ret = false;
} else {
$err = "Missing extension for ".$this->dataProvider;
$ret = 0;
}
- if ($fn = $this->raiseErrorFn)
+ if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
-
+ }
$this->_connectionID = false;
- if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
+ if ($this->debug) {
+ ADOConnection::outp( $this->host.': '.$err);
+ }
return $ret;
}
- function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName)
- {
+ function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) {
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName);
}
@@ -582,8 +628,7 @@ if (!defined('_ADODB_LAYER')) {
*
* @return true or false
*/
- function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "")
- {
+ function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") {
return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName, true);
}
@@ -597,23 +642,35 @@ if (!defined('_ADODB_LAYER')) {
*
* @return return true or false
*/
- function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "")
- {
+ function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") {
- if (defined('ADODB_NEVER_PERSIST'))
+ if (defined('ADODB_NEVER_PERSIST')) {
return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName);
+ }
- if ($argHostname != "") $this->host = $argHostname;
- if ($argUsername != "") $this->user = $argUsername;
- if ($argPassword != "") $this->password = 'not stored';
- if ($argDatabaseName != "") $this->database = $argDatabaseName;
+ if ($argHostname != "") {
+ $this->host = $argHostname;
+ }
+ if ($argUsername != "") {
+ $this->user = $argUsername;
+ }
+ if ($argPassword != "") {
+ $this->password = 'not stored';
+ }
+ if ($argDatabaseName != "") {
+ $this->database = $argDatabaseName;
+ }
$this->_isPersistentConnection = true;
- if ($rez = $this->_pconnect($this->host, $this->user, $argPassword, $this->database)) return true;
+ if ($rez = $this->_pconnect($this->host, $this->user, $argPassword, $this->database)) {
+ return true;
+ }
if (isset($rez)) {
$err = $this->ErrorMsg();
- if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'";
+ if (empty($err)) {
+ $err = "Connection error to server '$argHostname' with user '$argUsername'";
+ }
$ret = false;
} else {
$err = "Missing extension for ".$this->dataProvider;
@@ -624,12 +681,13 @@ if (!defined('_ADODB_LAYER')) {
}
$this->_connectionID = false;
- if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
+ if ($this->debug) {
+ ADOConnection::outp( $this->host.': '.$err);
+ }
return $ret;
}
- function outp_throw($msg,$src='WARN',$sql='')
- {
+ function outp_throw($msg,$src='WARN',$sql='') {
if (defined('ADODB_ERROR_HANDLER') && ADODB_ERROR_HANDLER == 'adodb_throw') {
adodb_throw($this->databaseType,$src,-9999,$msg,$sql,false,$this);
return;
@@ -638,24 +696,26 @@ if (!defined('_ADODB_LAYER')) {
}
// create cache class. Code is backward compat with old memcache implementation
- function _CreateCache()
- {
+ function _CreateCache() {
global $ADODB_CACHE, $ADODB_CACHE_CLASS;
if ($this->memCache) {
global $ADODB_INCLUDED_MEMCACHE;
- if (empty($ADODB_INCLUDED_MEMCACHE)) include(ADODB_DIR.'/adodb-memcache.lib.inc.php');
- $ADODB_CACHE = new ADODB_Cache_MemCache($this);
- } else
- $ADODB_CACHE = new $ADODB_CACHE_CLASS($this);
-
+ if (empty($ADODB_INCLUDED_MEMCACHE)) {
+ include(ADODB_DIR.'/adodb-memcache.lib.inc.php');
+ }
+ $ADODB_CACHE = new ADODB_Cache_MemCache($this);
+ } else {
+ $ADODB_CACHE = new $ADODB_CACHE_CLASS($this);
+ }
}
// Format date column in sql string given an input format that understands Y M D
- function SQLDate($fmt, $col=false)
- {
- if (!$col) $col = $this->sysDate;
+ function SQLDate($fmt, $col=false) {
+ if (!$col) {
+ $col = $this->sysDate;
+ }
return $col; // child class implement
}
@@ -671,11 +731,10 @@ if (!defined('_ADODB_LAYER')) {
* @param sql SQL to send to database
*
* @return return FALSE, or the prepared statement, or the original sql if
- * if the database does not support prepare.
+ * if the database does not support prepare.
*
*/
- function Prepare($sql)
- {
+ function Prepare($sql) {
return $sql;
}
@@ -690,41 +749,38 @@ if (!defined('_ADODB_LAYER')) {
* @param sql SQL to send to database
*
* @return return FALSE, or the prepared statement, or the original sql if
- * if the database does not support prepare.
+ * if the database does not support prepare.
*
*/
- function PrepareSP($sql,$param=true)
- {
+ function PrepareSP($sql,$param=true) {
return $this->Prepare($sql,$param);
}
/**
* PEAR DB Compat
*/
- function Quote($s)
- {
+ function Quote($s) {
return $this->qstr($s,false);
}
/**
- Requested by "Karsten Dambekalns" <k.dambekalns@fishfarm.de>
- */
- function QMagic($s)
- {
+ * Requested by "Karsten Dambekalns" <k.dambekalns@fishfarm.de>
+ */
+ function QMagic($s) {
return $this->qstr($s,get_magic_quotes_gpc());
}
- function q(&$s)
- {
- #if (!empty($this->qNull)) if ($s == 'null') return $s;
+ function q(&$s) {
+ //if (!empty($this->qNull && $s == 'null') {
+ // return $s;
+ //}
$s = $this->qstr($s,false);
}
/**
* PEAR DB Compat - do not use internally.
*/
- function ErrorNative()
- {
+ function ErrorNative() {
return $this->ErrorNo();
}
@@ -732,30 +788,26 @@ if (!defined('_ADODB_LAYER')) {
/**
* PEAR DB Compat - do not use internally.
*/
- function nextId($seq_name)
- {
+ function nextId($seq_name) {
return $this->GenID($seq_name);
}
/**
- * Lock a row, will escalate and lock the table if row locking not supported
- * will normally free the lock at the end of the transaction
+ * Lock a row, will escalate and lock the table if row locking not supported
+ * will normally free the lock at the end of the transaction
*
- * @param $table name of table to lock
- * @param $where where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
+ * @param $table name of table to lock
+ * @param $where where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
*/
- function RowLock($table,$where,$col='1 as adodbignore')
- {
+ function RowLock($table,$where,$col='1 as adodbignore') {
return false;
}
- function CommitLock($table)
- {
+ function CommitLock($table) {
return $this->CommitTrans();
}
- function RollbackLock($table)
- {
+ function RollbackLock($table) {
return $this->RollbackTrans();
}
@@ -763,13 +815,12 @@ if (!defined('_ADODB_LAYER')) {
* PEAR DB Compat - do not use internally.
*
* The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical
- * for easy porting :-)
+ * for easy porting :-)
*
* @param mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
* @returns The previous fetch mode
*/
- function SetFetchMode($mode)
- {
+ function SetFetchMode($mode) {
$old = $this->fetchMode;
$this->fetchMode = $mode;
@@ -784,10 +835,11 @@ if (!defined('_ADODB_LAYER')) {
/**
* PEAR DB Compat - do not use internally.
*/
- function Query($sql, $inputarr=false)
- {
+ function Query($sql, $inputarr=false) {
$rs = $this->Execute($sql, $inputarr);
- if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
+ if (!$rs && defined('ADODB_PEAR')) {
+ return ADODB_PEAR_Error();
+ }
return $rs;
}
@@ -795,10 +847,11 @@ if (!defined('_ADODB_LAYER')) {
/**
* PEAR DB Compat - do not use internally
*/
- function LimitQuery($sql, $offset, $count, $params=false)
- {
+ function LimitQuery($sql, $offset, $count, $params=false) {
$rs = $this->SelectLimit($sql, $count, $offset, $params);
- if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
+ if (!$rs && defined('ADODB_PEAR')) {
+ return ADODB_PEAR_Error();
+ }
return $rs;
}
@@ -806,8 +859,7 @@ if (!defined('_ADODB_LAYER')) {
/**
* PEAR DB Compat - do not use internally
*/
- function Disconnect()
- {
+ function Disconnect() {
return $this->Close();
}
@@ -824,23 +876,20 @@ if (!defined('_ADODB_LAYER')) {
* @param string $type (unused)
* @return string query parameter placeholder
*/
- function Param($name,$type='C')
- {
+ function Param($name,$type='C') {
return '?';
}
/*
InParameter and OutParameter are self-documenting versions of Parameter().
*/
- function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
- {
+ function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) {
return $this->Parameter($stmt,$var,$name,false,$maxLen,$type);
}
/*
*/
- function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
- {
+ function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) {
return $this->Parameter($stmt,$var,$name,true,$maxLen,$type);
}
@@ -861,14 +910,12 @@ if (!defined('_ADODB_LAYER')) {
@param [$type] The data type of $var. Legal values depend on driver.
*/
- function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)
- {
+ function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) {
return false;
}
- function IgnoreErrors($saveErrs=false)
- {
+ function IgnoreErrors($saveErrs=false) {
if (!$saveErrs) {
$saveErrs = array($this->raiseErrorFn,$this->_transOK);
$this->raiseErrorFn = false;
@@ -880,17 +927,16 @@ if (!defined('_ADODB_LAYER')) {
}
/**
- Improved method of initiating a transaction. Used together with CompleteTrans().
- Advantages include:
-
- a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans.
- Only the outermost block is treated as a transaction.<br>
- b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.<br>
- c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block
- are disabled, making it backward compatible.
- */
- function StartTrans($errfn = 'ADODB_TransMonitor')
- {
+ * Improved method of initiating a transaction. Used together with CompleteTrans().
+ * Advantages include:
+ *
+ * a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans.
+ * Only the outermost block is treated as a transaction.<br>
+ * b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.<br>
+ * c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block
+ * are disabled, making it backward compatible.
+ */
+ function StartTrans($errfn = 'ADODB_TransMonitor') {
if ($this->transOff > 0) {
$this->transOff += 1;
return true;
@@ -900,7 +946,9 @@ if (!defined('_ADODB_LAYER')) {
$this->raiseErrorFn = $errfn;
$this->_transOK = true;
- if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans");
+ if ($this->debug && $this->transCnt > 0) {
+ ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans");
+ }
$ok = $this->BeginTrans();
$this->transOff = 1;
return $ok;
@@ -915,8 +963,7 @@ if (!defined('_ADODB_LAYER')) {
and if set to false force rollback even if no SQL error detected.
@returns true on commit, false on rollback.
*/
- function CompleteTrans($autoComplete = true)
- {
+ function CompleteTrans($autoComplete = true) {
if ($this->transOff > 1) {
$this->transOff -= 1;
return true;
@@ -927,13 +974,20 @@ if (!defined('_ADODB_LAYER')) {
if ($this->_transOK && $autoComplete) {
if (!$this->CommitTrans()) {
$this->_transOK = false;
- if ($this->debug) ADOConnection::outp("Smart Commit failed");
- } else
- if ($this->debug) ADOConnection::outp("Smart Commit occurred");
+ if ($this->debug) {
+ ADOConnection::outp("Smart Commit failed");
+ }
+ } else {
+ if ($this->debug) {
+ ADOConnection::outp("Smart Commit occurred");
+ }
+ }
} else {
$this->_transOK = false;
$this->RollbackTrans();
- if ($this->debug) ADOCOnnection::outp("Smart Rollback occurred");
+ if ($this->debug) {
+ ADOCOnnection::outp("Smart Rollback occurred");
+ }
}
return $this->_transOK;
@@ -942,8 +996,7 @@ if (!defined('_ADODB_LAYER')) {
/*
At the end of a StartTrans/CompleteTrans block, perform a rollback.
*/
- function FailTrans()
- {
+ function FailTrans() {
if ($this->debug)
if ($this->transOff == 0) {
ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans");
@@ -957,9 +1010,10 @@ if (!defined('_ADODB_LAYER')) {
/**
Check if transaction has failed, only for Smart Transactions.
*/
- function HasFailedTrans()
- {
- if ($this->transOff > 0) return $this->_transOK == false;
+ function HasFailedTrans() {
+ if ($this->transOff > 0) {
+ return $this->_transOK == false;
+ }
return false;
}
@@ -968,17 +1022,20 @@ if (!defined('_ADODB_LAYER')) {
*
* @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text)
* @param [inputarr] holds the input data to bind to. Null elements will be set to null.
- * @return RecordSet or false
+ * @return RecordSet or false
*/
- function Execute($sql,$inputarr=false)
- {
+ function Execute($sql,$inputarr=false) {
if ($this->fnExecute) {
$fn = $this->fnExecute;
$ret = $fn($this,$sql,$inputarr);
- if (isset($ret)) return $ret;
+ if (isset($ret)) {
+ return $ret;
+ }
}
if ($inputarr !== false) {
- if (!is_array($inputarr)) $inputarr = array($inputarr);
+ if (!is_array($inputarr)) {
+ $inputarr = array($inputarr);
+ }
$element0 = reset($inputarr);
# is_object check because oci8 descriptors can be passed in
@@ -990,7 +1047,9 @@ if (!defined('_ADODB_LAYER')) {
if (!is_array($sql) && !$this->_bindInputArray) {
$sqlarr = explode('?',$sql);
$nparams = sizeof($sqlarr)-1;
- if (!$array_2d) $inputarr = array($inputarr);
+ if (!$array_2d) {
+ $inputarr = array($inputarr);
+ }
foreach($inputarr as $arr) {
$sql = ''; $i = 0;
@@ -1000,43 +1059,57 @@ if (!defined('_ADODB_LAYER')) {
// from Ron Baldwin <ron.baldwin#sourceprose.com>
// Only quote string types
$typ = gettype($v);
- if ($typ == 'string')
+ if ($typ == 'string') {
//New memory copy of input created here -mikefedyk
$sql .= $this->qstr($v);
- else if ($typ == 'double')
+ } else if ($typ == 'double') {
$sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1
- else if ($typ == 'boolean')
+ } else if ($typ == 'boolean') {
$sql .= $v ? $this->true : $this->false;
- else if ($typ == 'object') {
- if (method_exists($v, '__toString')) $sql .= $this->qstr($v->__toString());
- else $sql .= $this->qstr((string) $v);
- } else if ($v === null)
+ } else if ($typ == 'object') {
+ if (method_exists($v, '__toString')) {
+ $sql .= $this->qstr($v->__toString());
+ } else {
+ $sql .= $this->qstr((string) $v);
+ }
+ } else if ($v === null) {
$sql .= 'NULL';
- else
+ } else {
$sql .= $v;
+ }
$i += 1;
- if ($i == $nparams) break;
+ if ($i == $nparams) {
+ break;
+ }
} // while
if (isset($sqlarr[$i])) {
$sql .= $sqlarr[$i];
- if ($i+1 != sizeof($sqlarr)) $this->outp_throw( "Input Array does not match ?: ".htmlspecialchars($sql),'Execute');
- } else if ($i != sizeof($sqlarr))
+ if ($i+1 != sizeof($sqlarr)) {
+ $this->outp_throw( "Input Array does not match ?: ".htmlspecialchars($sql),'Execute');
+ }
+ } else if ($i != sizeof($sqlarr)) {
$this->outp_throw( "Input array does not match ?: ".htmlspecialchars($sql),'Execute');
+ }
$ret = $this->_Execute($sql);
- if (!$ret) return $ret;
+ if (!$ret) {
+ return $ret;
+ }
}
} else {
if ($array_2d) {
- if (is_string($sql))
+ if (is_string($sql)) {
$stmt = $this->Prepare($sql);
- else
+ } else {
$stmt = $sql;
+ }
foreach($inputarr as $arr) {
$ret = $this->_Execute($stmt,$arr);
- if (!$ret) return $ret;
+ if (!$ret) {
+ return $ret;
+ }
}
} else {
$ret = $this->_Execute($sql,$inputarr);
@@ -1050,11 +1123,12 @@ if (!defined('_ADODB_LAYER')) {
}
- function _Execute($sql,$inputarr=false)
- {
+ function _Execute($sql,$inputarr=false) {
if ($this->debug) {
global $ADODB_INCLUDED_LIB;
- if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
+ if (empty($ADODB_INCLUDED_LIB)) {
+ include(ADODB_DIR.'/adodb-lib.inc.php');
+ }
$this->_queryID = _adodb_debug_execute($this, $sql,$inputarr);
} else {
$this->_queryID = @$this->_query($sql,$inputarr);
@@ -1064,8 +1138,11 @@ if (!defined('_ADODB_LAYER')) {
// OK, query executed
// ************************
- if ($this->_queryID === false) { // error handling if query fails
- if ($this->debug == 99) adodb_backtrace(true,5);
+ // error handling if query fails
+ if ($this->_queryID === false) {
+ if ($this->debug == 99) {
+ adodb_backtrace(true,5);
+ }
$fn = $this->raiseErrorFn;
if ($fn) {
$fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this);
@@ -1073,7 +1150,8 @@ if (!defined('_ADODB_LAYER')) {
return false;
}
- if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead
+ // return simplified recordset for inserts/updates/deletes with lower overhead
+ if ($this->_queryID === true) {
$rsclass = $this->rsPrefix.'empty';
$rs = (class_exists($rsclass)) ? new $rsclass(): new ADORecordSet_empty();
@@ -1085,8 +1163,11 @@ if (!defined('_ADODB_LAYER')) {
$rs = new $rsclass($this->_queryID,$this->fetchMode);
$rs->connection = $this; // Pablo suggestion
$rs->Init();
- if (is_array($sql)) $rs->sql = $sql[0];
- else $rs->sql = $sql;
+ if (is_array($sql)) {
+ $rs->sql = $sql[0];
+ } else {
+ $rs->sql = $sql;
+ }
if ($rs->_numOfRows <= 0) {
global $ADODB_COUNTRECS;
if ($ADODB_COUNTRECS) {
@@ -1100,15 +1181,17 @@ if (!defined('_ADODB_LAYER')) {
return $rs;
}
- function CreateSequence($seqname='adodbseq',$startID=1)
- {
- if (empty($this->_genSeqSQL)) return false;
+ function CreateSequence($seqname='adodbseq',$startID=1) {
+ if (empty($this->_genSeqSQL)) {
+ return false;
+ }
return $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
}
- function DropSequence($seqname='adodbseq')
- {
- if (empty($this->_dropSeqSQL)) return false;
+ function DropSequence($seqname='adodbseq') {
+ if (empty($this->_dropSeqSQL)) {
+ return false;
+ }
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
}
@@ -1120,8 +1203,7 @@ if (!defined('_ADODB_LAYER')) {
* @param startID if sequence does not exist, start at this ID
* @return 0 if not supported, otherwise a sequence id
*/
- function GenID($seqname='adodbseq',$startID=1)
- {
+ function GenID($seqname='adodbseq',$startID=1) {
if (!$this->hasGenID) {
return 0; // formerly returns false pre 1.60
}
@@ -1140,10 +1222,15 @@ if (!defined('_ADODB_LAYER')) {
$createseq = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
$rs = $this->Execute($getnext);
}
- if ($rs && !$rs->EOF) $this->genID = reset($rs->fields);
- else $this->genID = 0; // false
+ if ($rs && !$rs->EOF) {
+ $this->genID = reset($rs->fields);
+ } else {
+ $this->genID = 0; // false
+ }
- if ($rs) $rs->Close();
+ if ($rs) {
+ $rs->Close();
+ }
return $this->genID;
}
@@ -1153,10 +1240,13 @@ if (!defined('_ADODB_LAYER')) {
* @param $column string name of the column, not needed by all databases (eg. mysql), default ''
* @return the last inserted ID. Not all databases support this.
*/
- function Insert_ID($table='',$column='')
- {
- if ($this->_logsql && $this->lastInsID) return $this->lastInsID;
- if ($this->hasInsertID) return $this->_insertid($table,$column);
+ function Insert_ID($table='',$column='') {
+ if ($this->_logsql && $this->lastInsID) {
+ return $this->lastInsID;
+ }
+ if ($this->hasInsertID) {
+ return $this->_insertid($table,$column);
+ }
if ($this->debug) {
ADOConnection::outp( '<p>Insert_ID error</p>');
adodb_backtrace();
@@ -1171,29 +1261,31 @@ if (!defined('_ADODB_LAYER')) {
* @return the last inserted ID. All databases support this. But aware possible
* problems in multiuser environments. Heavy test this before deploying.
*/
- function PO_Insert_ID($table="", $id="")
- {
- if ($this->hasInsertID){
- return $this->Insert_ID($table,$id);
- } else {
- return $this->GetOne("SELECT MAX($id) FROM $table");
- }
+ function PO_Insert_ID($table="", $id="") {
+ if ($this->hasInsertID){
+ return $this->Insert_ID($table,$id);
+ } else {
+ return $this->GetOne("SELECT MAX($id) FROM $table");
+ }
}
/**
* @return # rows affected by UPDATE/DELETE
*/
- function Affected_Rows()
- {
+ function Affected_Rows() {
if ($this->hasAffectedRows) {
if ($this->fnExecute === 'adodb_log_sql') {
- if ($this->_logsql && $this->_affected !== false) return $this->_affected;
+ if ($this->_logsql && $this->_affected !== false) {
+ return $this->_affected;
+ }
}
$val = $this->_affectedrows();
return ($val < 0) ? false : $val;
}
- if ($this->debug) ADOConnection::outp( '<p>Affected_Rows error</p>',false);
+ if ($this->debug) {
+ ADOConnection::outp( '<p>Affected_Rows error</p>',false);
+ }
return false;
}
@@ -1201,30 +1293,31 @@ if (!defined('_ADODB_LAYER')) {
/**
* @return the last error message
*/
- function ErrorMsg()
- {
- if ($this->_errorMsg) return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg;
- else return '';
+ function ErrorMsg() {
+ if ($this->_errorMsg) {
+ return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg;
+ } else {
+ return '';
+ }
}
/**
* @return the last error number. Normally 0 means no error.
*/
- function ErrorNo()
- {
+ function ErrorNo() {
return ($this->_errorMsg) ? -1 : 0;
}
- function MetaError($err=false)
- {
+ function MetaError($err=false) {
include_once(ADODB_DIR."/adodb-error.inc.php");
- if ($err === false) $err = $this->ErrorNo();
+ if ($err === false) {
+ $err = $this->ErrorNo();
+ }
return adodb_error($this->dataProvider,$this->databaseType,$err);
}
- function MetaErrorMsg($errno)
- {
+ function MetaErrorMsg($errno) {
include_once(ADODB_DIR."/adodb-error.inc.php");
return adodb_errormsg($errno);
}
@@ -1232,38 +1325,39 @@ if (!defined('_ADODB_LAYER')) {
/**
* @returns an array with the primary key columns in it.
*/
- function MetaPrimaryKeys($table, $owner=false)
- {
+ function MetaPrimaryKeys($table, $owner=false) {
// owner not used in base class - see oci8
$p = array();
$objs = $this->MetaColumns($table);
if ($objs) {
foreach($objs as $v) {
- if (!empty($v->primary_key))
+ if (!empty($v->primary_key)) {
$p[] = $v->name;
+ }
}
}
- if (sizeof($p)) return $p;
- if (function_exists('ADODB_VIEW_PRIMARYKEYS'))
+ if (sizeof($p)) {
+ return $p;
+ }
+ if (function_exists('ADODB_VIEW_PRIMARYKEYS')) {
return ADODB_VIEW_PRIMARYKEYS($this->databaseType, $this->database, $table, $owner);
+ }
return false;
}
/**
* @returns assoc array where keys are tables, and values are foreign keys
*/
- function MetaForeignKeys($table, $owner=false, $upper=false)
- {
+ function MetaForeignKeys($table, $owner=false, $upper=false) {
return false;
}
/**
* Choose a database to connect to. Many databases do not support this.
*
- * @param dbName is the name of the database to select
- * @return true or false
+ * @param dbName is the name of the database to select
+ * @return true or false
*/
- function SelectDB($dbName)
- {return false;}
+ function SelectDB($dbName) {return false;}
/**
@@ -1285,17 +1379,18 @@ if (!defined('_ADODB_LAYER')) {
* @param [secs2cache] is a private parameter only used by jlim
* @return the recordset ($rs->databaseType == 'array')
*/
- function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
- {
+ function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) {
if ($this->hasTop && $nrows > 0) {
- // suggested by Reinhard Balling. Access requires top after distinct
- // Informix requires first before distinct - F Riosa
+ // suggested by Reinhard Balling. Access requires top after distinct
+ // Informix requires first before distinct - F Riosa
$ismssql = (strpos($this->databaseType,'mssql') !== false);
- if ($ismssql) $isaccess = false;
- else $isaccess = (strpos($this->databaseType,'access') !== false);
-
- if ($offset <= 0) {
+ if ($ismssql) {
+ $isaccess = false;
+ } else {
+ $isaccess = (strpos($this->databaseType,'access') !== false);
+ }
+ if ($offset <= 0) {
// access includes ties in result
if ($isaccess) {
$sql = preg_replace(
@@ -1334,8 +1429,11 @@ if (!defined('_ADODB_LAYER')) {
$ADODB_COUNTRECS = false;
- if ($secs2cache != 0) $rs = $this->CacheExecute($secs2cache,$sql,$inputarr);
- else $rs = $this->Execute($sql,$inputarr);
+ if ($secs2cache != 0) {
+ $rs = $this->CacheExecute($secs2cache,$sql,$inputarr);
+ } else {
+ $rs = $this->Execute($sql,$inputarr);
+ }
$ADODB_COUNTRECS = $savec;
if ($rs && !$rs->EOF) {
@@ -1350,8 +1448,7 @@ if (!defined('_ADODB_LAYER')) {
*
* @param rs the recordset to serialize
*/
- function SerializableRS(&$rs)
- {
+ function SerializableRS(&$rs) {
$rs2 = $this->_rs2rs($rs);
$ignore = false;
$rs2->connection = $ignore;
@@ -1365,12 +1462,11 @@ if (!defined('_ADODB_LAYER')) {
* old $rs will be closed.
*
* @param rs the recordset to copy
- * @param [nrows] number of rows to retrieve (optional)
- * @param [offset] offset by number of rows (optional)
- * @return the new recordset
+ * @param [nrows] number of rows to retrieve (optional)
+ * @param [offset] offset by number of rows (optional)
+ * @return the new recordset
*/
- function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true)
- {
+ function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true) {
if (! $rs) {
return false;
}
@@ -1391,7 +1487,9 @@ if (!defined('_ADODB_LAYER')) {
$arr = $rs->GetArrayLimit($nrows,$offset);
//print_r($arr);
- if ($close) $rs->Close();
+ if ($close) {
+ $rs->Close();
+ }
$arrayClass = $this->arrayClass;
@@ -1407,14 +1505,12 @@ if (!defined('_ADODB_LAYER')) {
/*
* Return all rows. Compat with PEAR DB
*/
- function GetAll($sql, $inputarr=false)
- {
+ function GetAll($sql, $inputarr=false) {
$arr = $this->GetArray($sql,$inputarr);
return $arr;
}
- function GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false)
- {
+ function GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false) {
$rs = $this->Execute($sql, $inputarr);
if (!$rs) {
return false;
@@ -1423,8 +1519,7 @@ if (!defined('_ADODB_LAYER')) {
return $arr;
}
- function CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false)
- {
+ function CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false) {
if (!is_numeric($secs2cache)) {
$first2cols = $force_array;
$force_array = $inputarr;
@@ -1444,8 +1539,7 @@ if (!defined('_ADODB_LAYER')) {
* @param sql SQL statement
* @param [inputarr] input bind array
*/
- function GetOne($sql,$inputarr=false)
- {
+ function GetOne($sql,$inputarr=false) {
global $ADODB_COUNTRECS,$ADODB_GETONE_EOF;
$crecs = $ADODB_COUNTRECS;
@@ -1454,8 +1548,11 @@ if (!defined('_ADODB_LAYER')) {
$ret = false;
$rs = $this->Execute($sql,$inputarr);
if ($rs) {
- if ($rs->EOF) $ret = $ADODB_GETONE_EOF;
- else $ret = reset($rs->fields);
+ if ($rs->EOF) {
+ $ret = $ADODB_GETONE_EOF;
+ } else {
+ $ret = reset($rs->fields);
+ }
$rs->Close();
}
@@ -1464,81 +1561,84 @@ if (!defined('_ADODB_LAYER')) {
}
// $where should include 'WHERE fld=value'
- function GetMedian($table, $field,$where = '')
- {
+ function GetMedian($table, $field,$where = '') {
$total = $this->GetOne("select count(*) from $table $where");
- if (!$total) return false;
+ if (!$total) {
+ return false;
+ }
$midrow = (integer) ($total/2);
$rs = $this->SelectLimit("select $field from $table $where order by 1",1,$midrow);
- if ($rs && !$rs->EOF) return reset($rs->fields);
+ if ($rs && !$rs->EOF) {
+ return reset($rs->fields);
+ }
return false;
}
- function CacheGetOne($secs2cache,$sql=false,$inputarr=false)
- {
+ function CacheGetOne($secs2cache,$sql=false,$inputarr=false) {
global $ADODB_GETONE_EOF;
$ret = false;
$rs = $this->CacheExecute($secs2cache,$sql,$inputarr);
if ($rs) {
- if ($rs->EOF) $ret = $ADODB_GETONE_EOF;
- else $ret = reset($rs->fields);
+ if ($rs->EOF) {
+ $ret = $ADODB_GETONE_EOF;
+ } else {
+ $ret = reset($rs->fields);
+ }
$rs->Close();
}
return $ret;
}
- function GetCol($sql, $inputarr = false, $trim = false)
- {
+ function GetCol($sql, $inputarr = false, $trim = false) {
- $rs = $this->Execute($sql, $inputarr);
- if ($rs) {
+ $rs = $this->Execute($sql, $inputarr);
+ if ($rs) {
$rv = array();
- if ($trim) {
+ if ($trim) {
while (!$rs->EOF) {
$rv[] = trim(reset($rs->fields));
$rs->MoveNext();
- }
+ }
} else {
while (!$rs->EOF) {
$rv[] = reset($rs->fields);
$rs->MoveNext();
- }
+ }
}
- $rs->Close();
- } else
+ $rs->Close();
+ } else {
$rv = false;
- return $rv;
+ }
+ return $rv;
}
- function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false)
- {
- $rs = $this->CacheExecute($secs, $sql, $inputarr);
- if ($rs) {
+ function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false) {
+ $rs = $this->CacheExecute($secs, $sql, $inputarr);
+ if ($rs) {
$rv = array();
if ($trim) {
while (!$rs->EOF) {
$rv[] = trim(reset($rs->fields));
$rs->MoveNext();
- }
+ }
} else {
while (!$rs->EOF) {
$rv[] = reset($rs->fields);
$rs->MoveNext();
- }
+ }
}
- $rs->Close();
- } else
+ $rs->Close();
+ } else
$rv = false;
- return $rv;
+ return $rv;
}
- function Transpose(&$rs,$addfieldnames=true)
- {
+ function Transpose(&$rs,$addfieldnames=true) {
$rs2 = $this->_rs2rs($rs);
if (!$rs2) {
return false;
@@ -1555,9 +1655,10 @@ if (!defined('_ADODB_LAYER')) {
If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour.
*/
- function OffsetDate($dayFraction,$date=false)
- {
- if (!$date) $date = $this->sysDate;
+ function OffsetDate($dayFraction,$date=false) {
+ if (!$date) {
+ $date = $this->sysDate;
+ }
return '('.$date.'+'.$dayFraction.')';
}
@@ -1567,8 +1668,7 @@ if (!defined('_ADODB_LAYER')) {
* @param sql SQL statement
* @param [inputarr] input bind array
*/
- function GetArray($sql,$inputarr=false)
- {
+ function GetArray($sql,$inputarr=false) {
global $ADODB_COUNTRECS;
$savec = $ADODB_COUNTRECS;
@@ -1587,14 +1687,12 @@ if (!defined('_ADODB_LAYER')) {
return $arr;
}
- function CacheGetAll($secs2cache,$sql=false,$inputarr=false)
- {
+ function CacheGetAll($secs2cache,$sql=false,$inputarr=false) {
$arr = $this->CacheGetArray($secs2cache,$sql,$inputarr);
return $arr;
}
- function CacheGetArray($secs2cache,$sql=false,$inputarr=false)
- {
+ function CacheGetArray($secs2cache,$sql=false,$inputarr=false) {
global $ADODB_COUNTRECS;
$savec = $ADODB_COUNTRECS;
@@ -1614,8 +1712,7 @@ if (!defined('_ADODB_LAYER')) {
return $arr;
}
- function GetRandRow($sql, $arr= false)
- {
+ function GetRandRow($sql, $arr= false) {
$rezarr = $this->GetAll($sql, $arr);
$sz = sizeof($rezarr);
return $rezarr[abs(rand()) % $sz];
@@ -1628,8 +1725,7 @@ if (!defined('_ADODB_LAYER')) {
* @param sql SQL statement
* @param [inputarr] input bind array
*/
- function GetRow($sql,$inputarr=false)
- {
+ function GetRow($sql,$inputarr=false) {
global $ADODB_COUNTRECS;
$crecs = $ADODB_COUNTRECS;
@@ -1639,8 +1735,11 @@ if (!defined('_ADODB_LAYER')) {
$ADODB_COUNTRECS = $crecs;
if ($rs) {
- if (!$rs->EOF) $arr = $rs->fields;
- else $arr = array();
+ if (!$rs->EOF) {
+ $arr = $rs->fields;
+ } else {
+ $arr = array();
+ }
$rs->Close();
return $arr;
}
@@ -1648,12 +1747,14 @@ if (!defined('_ADODB_LAYER')) {
return false;
}
- function CacheGetRow($secs2cache,$sql=false,$inputarr=false)
- {
+ function CacheGetRow($secs2cache,$sql=false,$inputarr=false) {
$rs = $this->CacheExecute($secs2cache,$sql,$inputarr);
if ($rs) {
- if (!$rs->EOF) $arr = $rs->fields;
- else $arr = array();
+ if (!$rs->EOF) {
+ $arr = $rs->fields;
+ } else {
+ $arr = array();
+ }
$rs->Close();
return $arr;
@@ -1681,10 +1782,11 @@ if (!defined('_ADODB_LAYER')) {
* returns 0 = fail, 1 = update, 2 = insert
*/
- function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false)
- {
+ function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false) {
global $ADODB_INCLUDED_LIB;
- if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
+ if (empty($ADODB_INCLUDED_LIB)) {
+ include(ADODB_DIR.'/adodb-lib.inc.php');
+ }
return _adodb_replace($this, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc);
}
@@ -1708,40 +1810,40 @@ if (!defined('_ADODB_LAYER')) {
* @param [inputarr] array of bind variables
* @return the recordset ($rs->databaseType == 'array')
*/
- function CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false)
- {
+ function CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false) {
if (!is_numeric($secs2cache)) {
- if ($sql === false) $sql = -1;
- if ($offset == -1) $offset = false;
- // sql, nrows, offset,inputarr
+ if ($sql === false) {
+ $sql = -1;
+ }
+ if ($offset == -1) {
+ $offset = false;
+ }
+ // sql, nrows, offset,inputarr
$rs = $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$this->cacheSecs);
} else {
- if ($sql === false) $this->outp_throw("Warning: \$sql missing from CacheSelectLimit()",'CacheSelectLimit');
+ if ($sql === false) {
+ $this->outp_throw("Warning: \$sql missing from CacheSelectLimit()",'CacheSelectLimit');
+ }
$rs = $this->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
}
return $rs;
}
-
- /**
- * Flush cached recordsets that match a particular $sql statement.
- * If $sql == false, then we purge all files in the cache.
- */
-
/**
* Flush cached recordsets that match a particular $sql statement.
* If $sql == false, then we purge all files in the cache.
*/
- function CacheFlush($sql=false,$inputarr=false)
- {
+ function CacheFlush($sql=false,$inputarr=false) {
global $ADODB_CACHE_DIR, $ADODB_CACHE;
- if (empty($ADODB_CACHE)) return false;
+ if (empty($ADODB_CACHE)) {
+ return false;
+ }
if (!$sql) {
- $ADODB_CACHE->flushall($this->debug);
- return;
- }
+ $ADODB_CACHE->flushall($this->debug);
+ return;
+ }
$f = $this->_gencachename($sql.serialize($inputarr),false);
return $ADODB_CACHE->flushcache($f, $this->debug);
@@ -1762,8 +1864,7 @@ if (!defined('_ADODB_LAYER')) {
* Assuming that we can have 50,000 files per directory with good performance,
* then we can scale to 12.8 million unique cached recordsets. Wow!
*/
- function _gencachename($sql,$createdir)
- {
+ function _gencachename($sql,$createdir) {
global $ADODB_CACHE, $ADODB_CACHE_DIR;
if ($this->fetchMode === false) {
@@ -1773,9 +1874,14 @@ if (!defined('_ADODB_LAYER')) {
$mode = $this->fetchMode;
}
$m = md5($sql.$this->databaseType.$this->database.$this->user.$mode);
- if (!$ADODB_CACHE->createdir) return $m;
- if (!$createdir) $dir = $ADODB_CACHE->getdirname($m);
- else $dir = $ADODB_CACHE->createdir($m, $this->debug);
+ if (!$ADODB_CACHE->createdir) {
+ return $m;
+ }
+ if (!$createdir) {
+ $dir = $ADODB_CACHE->getdirname($m);
+ } else {
+ $dir = $ADODB_CACHE->createdir($m, $this->debug);
+ }
return $dir.'/adodb_'.$m.'.cache';
}
@@ -1788,13 +1894,14 @@ if (!defined('_ADODB_LAYER')) {
* This is an optional parameter.
* @param sql SQL statement to execute
* @param [inputarr] holds the input data to bind to
- * @return RecordSet or false
+ * @return RecordSet or false
*/
- function CacheExecute($secs2cache,$sql=false,$inputarr=false)
- {
+ function CacheExecute($secs2cache,$sql=false,$inputarr=false) {
global $ADODB_CACHE;
- if (empty($ADODB_CACHE)) $this->_CreateCache();
+ if (empty($ADODB_CACHE)) {
+ $this->_CreateCache();
+ }
if (!is_numeric($secs2cache)) {
$inputarr = $sql;
@@ -1827,13 +1934,14 @@ if (!defined('_ADODB_LAYER')) {
if (get_magic_quotes_runtime() && !$this->memCache) {
ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :(");
}
- if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (this is a notice and not an error)");
+ if ($this->debug !== -1) {
+ ADOConnection::outp( " $md5file cache failure: $err (this is a notice and not an error)");
+ }
}
$rs = $this->Execute($sqlparam,$inputarr);
if ($rs) {
-
$eof = $rs->EOF;
$rs = $this->_rs2rs($rs); // read entire recordset into memory immediately
$rs->timeCreated = time(); // used by caching
@@ -1854,7 +1962,9 @@ if (!defined('_ADODB_LAYER')) {
// do not call error handling for just a warning
}
- if ($this->debug) ADOConnection::outp( " ".$em);
+ if ($this->debug) {
+ ADOConnection::outp( " ".$em);
+ }
}
if ($rs->EOF && !$eof) {
$rs->MoveFirst();
@@ -1862,8 +1972,9 @@ if (!defined('_ADODB_LAYER')) {
$rs->connection = $this; // Pablo suggestion
}
- } else if (!$this->memCache)
+ } else if (!$this->memCache) {
$ADODB_CACHE->flushcache($md5file);
+ }
} else {
$this->_errorMsg = '';
$this->_errorCode = 0;
@@ -1872,14 +1983,18 @@ if (!defined('_ADODB_LAYER')) {
$fn = $this->fnCacheExecute;
$fn($this, $secs2cache, $sql, $inputarr);
}
- // ok, set cached object found
+ // ok, set cached object found
$rs->connection = $this; // Pablo suggestion
if ($this->debug){
- if ($this->debug == 99) adodb_backtrace();
+ if ($this->debug == 99) {
+ adodb_backtrace();
+ }
$inBrowser = isset($_SERVER['HTTP_USER_AGENT']);
$ttl = $rs->timeCreated + $secs2cache - time();
$s = is_array($sql) ? $sql[0] : $sql;
- if ($inBrowser) $s = '<i>'.htmlspecialchars($s).'</i>';
+ if ($inBrowser) {
+ $s = '<i>'.htmlspecialchars($s).'</i>';
+ }
ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]");
}
@@ -1895,8 +2010,7 @@ if (!defined('_ADODB_LAYER')) {
$forceUpdate means that even if the data has not changed, perform update.
*/
- function AutoExecute($table, $fields_values, $mode = 'INSERT', $where = false, $forceUpdate = true, $magicq = false)
- {
+ function AutoExecute($table, $fields_values, $mode = 'INSERT', $where = false, $forceUpdate = true, $magicq = false) {
if ($where === false && ($mode == 'UPDATE' || $mode == 2 /* DB_AUTOQUERY_UPDATE */) ) {
$this->outp_throw('AutoExecute: Illegal mode=UPDATE with empty WHERE clause', 'AutoExecute');
return false;
@@ -1904,7 +2018,9 @@ if (!defined('_ADODB_LAYER')) {
$sql = "SELECT * FROM $table";
$rs = $this->SelectLimit($sql, 1);
- if (!$rs) return false; // table does not exist
+ if (!$rs) {
+ return false; // table does not exist
+ }
$rs->tableName = $table;
if ($where !== false) {
@@ -1940,8 +2056,7 @@ if (!defined('_ADODB_LAYER')) {
*
* "Jonathan Younger" <jyounger@unilab.com>
*/
- function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null)
- {
+ function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null) {
global $ADODB_INCLUDED_LIB;
// ********************************************************
@@ -1953,7 +2068,9 @@ if (!defined('_ADODB_LAYER')) {
}
// ********************************************************
- if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
+ if (empty($ADODB_INCLUDED_LIB)) {
+ include(ADODB_DIR.'/adodb-lib.inc.php');
+ }
return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$force);
}
@@ -1965,14 +2082,15 @@ if (!defined('_ADODB_LAYER')) {
* Note: This function should only be used on a recordset
* that is run against a single table.
*/
- function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null)
- {
+ function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null) {
global $ADODB_INCLUDED_LIB;
if (!isset($force)) {
global $ADODB_FORCE_TYPE;
$force = $ADODB_FORCE_TYPE;
}
- if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
+ if (empty($ADODB_INCLUDED_LIB)) {
+ include(ADODB_DIR.'/adodb-lib.inc.php');
+ }
return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$force);
}
@@ -1995,9 +2113,7 @@ if (!defined('_ADODB_LAYER')) {
* $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
* $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
*/
-
- function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
- {
+ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') {
return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false;
}
@@ -2010,50 +2126,50 @@ if (!defined('_ADODB_LAYER')) {
* $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
* $conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1');
*/
- function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
- {
+ function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') {
$fd = fopen($path,'rb');
- if ($fd === false) return false;
+ if ($fd === false) {
+ return false;
+ }
$val = fread($fd,filesize($path));
fclose($fd);
return $this->UpdateBlob($table,$column,$val,$where,$blobtype);
}
- function BlobDecode($blob)
- {
+ function BlobDecode($blob) {
return $blob;
}
- function BlobEncode($blob)
- {
+ function BlobEncode($blob) {
return $blob;
}
- function SetCharSet($charset)
- {
+ function SetCharSet($charset) {
return false;
}
- function IfNull( $field, $ifNull )
- {
+ function IfNull( $field, $ifNull ) {
return " CASE WHEN $field is null THEN $ifNull ELSE $field END ";
}
- function LogSQL($enable=true)
- {
+ function LogSQL($enable=true) {
include_once(ADODB_DIR.'/adodb-perf.inc.php');
- if ($enable) $this->fnExecute = 'adodb_log_sql';
- else $this->fnExecute = false;
+ if ($enable) {
+ $this->fnExecute = 'adodb_log_sql';
+ } else {
+ $this->fnExecute = false;
+ }
$old = $this->_logsql;
$this->_logsql = $enable;
- if ($enable && !$old) $this->_affected = false;
+ if ($enable && !$old) {
+ $this->_affected = false;
+ }
return $old;
}
- function GetCharSet()
- {
+ function GetCharSet() {
return false;
}
@@ -2064,15 +2180,13 @@ if (!defined('_ADODB_LAYER')) {
* $conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');
* $conn->UpdateClob('clobtable','clobcol',$clob,'id=1');
*/
- function UpdateClob($table,$column,$val,$where)
- {
+ function UpdateClob($table,$column,$val,$where) {
return $this->UpdateBlob($table,$column,$val,$where,'CLOB');
}
// not the fastest implementation - quick and dirty - jlim
// for best performance, use the actual $rs->MetaType().
- function MetaType($t,$len=-1,$fieldobj=false)
- {
+ function MetaType($t,$len=-1,$fieldobj=false) {
if (empty($this->_metars)) {
$rsclass = $this->rsPrefix.$this->databaseType;
@@ -2087,8 +2201,7 @@ if (!defined('_ADODB_LAYER')) {
* Change the SQL connection locale to a specified locale.
* This is used to get the date formats written depending on the client locale.
*/
- function SetDateLocale($locale = 'En')
- {
+ function SetDateLocale($locale = 'En') {
$this->locale = $locale;
switch (strtoupper($locale))
{
@@ -2144,12 +2257,13 @@ if (!defined('_ADODB_LAYER')) {
global $_ADODB_ACTIVE_DBS;
## reduce overhead of adodb.inc.php -- moved to adodb-active-record.inc.php
## if adodb-active-recordx is loaded -- should be no issue as they will probably use Find()
- if (!isset($_ADODB_ACTIVE_DBS))include_once(ADODB_DIR.'/adodb-active-record.inc.php');
+ if (!isset($_ADODB_ACTIVE_DBS)) {
+ include_once(ADODB_DIR.'/adodb-active-record.inc.php');
+ }
return adodb_GetActiveRecordsClass($this, $class, $table, $whereOrderBy, $bindarr, $primkeyArr, $extra, $relations);
}
- function GetActiveRecords($table,$where=false,$bindarr=false,$primkeyArr=false)
- {
+ function GetActiveRecords($table,$where=false,$bindarr=false,$primkeyArr=false) {
$arr = $this->GetActiveRecordsClass('ADODB_Active_Record', $table, $where, $bindarr, $primkeyArr);
return $arr;
}
@@ -2157,8 +2271,7 @@ if (!defined('_ADODB_LAYER')) {
/**
* Close Connection
*/
- function Close()
- {
+ function Close() {
$rez = $this->_close();
$this->_connectionID = false;
return $rez;
@@ -2169,15 +2282,15 @@ if (!defined('_ADODB_LAYER')) {
*
* @return true if succeeded or false if database does not support transactions
*/
- function BeginTrans()
- {
- if ($this->debug) ADOConnection::outp("BeginTrans: Transactions not supported for this driver");
+ function BeginTrans() {
+ if ($this->debug) {
+ ADOConnection::outp("BeginTrans: Transactions not supported for this driver");
+ }
return false;
}
/* set transaction mode */
- function SetTransactionMode( $transaction_mode )
- {
+ function SetTransactionMode( $transaction_mode ) {
$transaction_mode = $this->MetaTransaction($transaction_mode, $this->dataProvider);
$this->_transmode = $transaction_mode;
}
@@ -2187,8 +2300,7 @@ http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-isolation.html
http://www.postgresql.org/docs/8.1/interactive/sql-set-transaction.html
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_10005.htm
*/
- function MetaTransaction($mode,$db)
- {
+ function MetaTransaction($mode,$db) {
$mode = strtoupper($mode);
$mode = str_replace('ISOLATION LEVEL ','',$mode);
@@ -2234,8 +2346,9 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return true/false.
*/
- function CommitTrans($ok=true)
- { return true;}
+ function CommitTrans($ok=true) {
+ return true;
+ }
/**
@@ -2243,8 +2356,9 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return true/false.
*/
- function RollbackTrans()
- { return false;}
+ function RollbackTrans() {
+ return false;
+ }
/**
@@ -2253,26 +2367,29 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return an array of database names.
*/
- function MetaDatabases()
- {
- global $ADODB_FETCH_MODE;
-
- if ($this->metaDatabasesSQL) {
- $save = $ADODB_FETCH_MODE;
- $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ function MetaDatabases() {
+ global $ADODB_FETCH_MODE;
- if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+ if ($this->metaDatabasesSQL) {
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- $arr = $this->GetCol($this->metaDatabasesSQL);
- if (isset($savem)) $this->SetFetchMode($savem);
- $ADODB_FETCH_MODE = $save;
+ if ($this->fetchMode !== false) {
+ $savem = $this->SetFetchMode(false);
+ }
- return $arr;
+ $arr = $this->GetCol($this->metaDatabasesSQL);
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
}
+ $ADODB_FETCH_MODE = $save;
- return false;
+ return $arr;
}
+ return false;
+ }
+
/**
* List procedures or functions in an array.
* @param procedureNamePattern a procedure name pattern; must match the procedure name as it is stored in the database
@@ -2290,15 +2407,14 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* )
* )
*/
- function MetaProcedures($procedureNamePattern = null, $catalog = null, $schemaPattern = null)
- {
+ function MetaProcedures($procedureNamePattern = null, $catalog = null, $schemaPattern = null) {
return false;
}
/**
* @param ttype can either be 'VIEW' or 'TABLE' or false.
- * If false, both views and tables are returned.
+ * If false, both views and tables are returned.
* "VIEW" returns only views
* "TABLE" returns only tables
* @param showSchema returns the schema/user with the table name, eg. USER.TABLE
@@ -2306,8 +2422,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return array of tables for current database.
*/
- function MetaTables($ttype=false,$showSchema=false,$mask=false)
- {
+ function MetaTables($ttype=false,$showSchema=false,$mask=false) {
global $ADODB_FETCH_MODE;
if ($mask) {
@@ -2317,10 +2432,14 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+ if ($this->fetchMode !== false) {
+ $savem = $this->SetFetchMode(false);
+ }
$rs = $this->Execute($this->metaTablesSQL);
- if (isset($savem)) $this->SetFetchMode($savem);
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
$ADODB_FETCH_MODE = $save;
if ($rs === false) {
@@ -2336,9 +2455,13 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
for ($i=0; $i < sizeof($arr); $i++) {
if ($hast) {
if ($showt == 0) {
- if (strncmp($arr[$i][1],'T',1) == 0) $arr2[] = trim($arr[$i][0]);
+ if (strncmp($arr[$i][1],'T',1) == 0) {
+ $arr2[] = trim($arr[$i][0]);
+ }
} else {
- if (strncmp($arr[$i][1],'V',1) == 0) $arr2[] = trim($arr[$i][0]);
+ if (strncmp($arr[$i][1],'V',1) == 0) {
+ $arr2[] = trim($arr[$i][0]);
+ }
}
} else
$arr2[] = trim($arr[$i][0]);
@@ -2350,8 +2473,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
}
- function _findschema(&$table,&$schema)
- {
+ function _findschema(&$table,&$schema) {
if (!$schema && ($at = strpos($table,'.')) !== false) {
$schema = substr($table,0,$at);
$table = substr($table,$at+1);
@@ -2368,20 +2490,22 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return array of ADOFieldObjects for current table.
*/
- function MetaColumns($table,$normalize=true)
- {
+ function MetaColumns($table,$normalize=true) {
global $ADODB_FETCH_MODE;
if (!empty($this->metaColumnsSQL)) {
-
$schema = false;
$this->_findschema($table,$schema);
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+ if ($this->fetchMode !== false) {
+ $savem = $this->SetFetchMode(false);
+ }
$rs = $this->Execute(sprintf($this->metaColumnsSQL,($normalize)?strtoupper($table):$table));
- if (isset($savem)) $this->SetFetchMode($savem);
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
$ADODB_FETCH_MODE = $save;
if ($rs === false || $rs->EOF) {
return false;
@@ -2393,14 +2517,22 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
if (isset($rs->fields[3]) && $rs->fields[3]) {
- if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3];
+ if ($rs->fields[3]>0) {
+ $fld->max_length = $rs->fields[3];
+ }
$fld->scale = $rs->fields[4];
- if ($fld->scale>0) $fld->max_length += 1;
- } else
+ if ($fld->scale>0) {
+ $fld->max_length += 1;
+ }
+ } else {
$fld->max_length = $rs->fields[2];
+ }
- if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
- else $retarr[strtoupper($fld->name)] = $fld;
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) {
+ $retarr[] = $fld;
+ } else {
+ $retarr[strtoupper($fld->name)] = $fld;
+ }
$rs->MoveNext();
}
$rs->Close();
@@ -2426,8 +2558,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* )
* )
*/
- function MetaIndexes($table, $primary = false, $owner = false)
- {
+ function MetaIndexes($table, $primary = false, $owner = false) {
return false;
}
@@ -2437,8 +2568,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return array of column names for current table.
*/
- function MetaColumnNames($table, $numIndexes=false,$useattnum=false /* only for postgres */)
- {
+ function MetaColumnNames($table, $numIndexes=false,$useattnum=false /* only for postgres */) {
$objarr = $this->MetaColumns($table);
if (!is_array($objarr)) {
return false;
@@ -2468,8 +2598,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return concatenated string
*/
- function Concat()
- {
+ function Concat() {
$arr = func_get_args();
return implode($this->concat_operator, $arr);
}
@@ -2482,39 +2611,48 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return date string in database date format
*/
- function DBDate($d, $isfld=false)
- {
- if (empty($d) && $d !== 0) return 'null';
- if ($isfld) return $d;
-
- if (is_object($d)) return $d->format($this->fmtDate);
-
+ function DBDate($d, $isfld=false) {
+ if (empty($d) && $d !== 0) {
+ return 'null';
+ }
+ if ($isfld) {
+ return $d;
+ }
+ if (is_object($d)) {
+ return $d->format($this->fmtDate);
+ }
if (is_string($d) && !is_numeric($d)) {
- if ($d === 'null') return $d;
+ if ($d === 'null') {
+ return $d;
+ }
if (strncmp($d,"'",1) === 0) {
$d = _adodb_safedateq($d);
return $d;
}
- if ($this->isoDates) return "'$d'";
+ if ($this->isoDates) {
+ return "'$d'";
+ }
$d = ADOConnection::UnixDate($d);
}
return adodb_date($this->fmtDate,$d);
}
- function BindDate($d)
- {
+ function BindDate($d) {
$d = $this->DBDate($d);
- if (strncmp($d,"'",1)) return $d;
+ if (strncmp($d,"'",1)) {
+ return $d;
+ }
return substr($d,1,strlen($d)-2);
}
- function BindTimeStamp($d)
- {
+ function BindTimeStamp($d) {
$d = $this->DBTimeStamp($d);
- if (strncmp($d,"'",1)) return $d;
+ if (strncmp($d,"'",1)) {
+ return $d;
+ }
return substr($d,1,strlen($d)-2);
}
@@ -2527,17 +2665,25 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return timestamp string in database timestamp format
*/
- function DBTimeStamp($ts,$isfld=false)
- {
- if (empty($ts) && $ts !== 0) return 'null';
- if ($isfld) return $ts;
- if (is_object($ts)) return $ts->format($this->fmtTimeStamp);
+ function DBTimeStamp($ts,$isfld=false) {
+ if (empty($ts) && $ts !== 0) {
+ return 'null';
+ }
+ if ($isfld) {
+ return $ts;
+ }
+ if (is_object($ts)) {
+ return $ts->format($this->fmtTimeStamp);
+ }
# strlen(14) allows YYYYMMDDHHMMSS format
- if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14))
+ if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14)) {
return adodb_date($this->fmtTimeStamp,$ts);
+ }
- if ($ts === 'null') return $ts;
+ if ($ts === 'null') {
+ return $ts;
+ }
if ($this->isoDates && strlen($ts) !== 14) {
$ts = _adodb_safedate($ts);
return "'$ts'";
@@ -2552,19 +2698,24 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/
- static function UnixDate($v)
- {
+ static function UnixDate($v) {
if (is_object($v)) {
// odbtp support
//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
}
- if (is_numeric($v) && strlen($v) !== 8) return $v;
- if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
- ($v), $rr)) return false;
+ if (is_numeric($v) && strlen($v) !== 8) {
+ return $v;
+ }
+ if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", $v, $rr)) {
+ return false;
+ }
+
+ if ($rr[1] <= TIMESTAMP_FIRST_YEAR) {
+ return 0;
+ }
- if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0;
// h-m-s-MM-DD-YY
return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
}
@@ -2576,8 +2727,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/
- static function UnixTimeStamp($v)
- {
+ static function UnixTimeStamp($v) {
if (is_object($v)) {
// odbtp support
//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
@@ -2588,11 +2738,15 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|",
($v), $rr)) return false;
- if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0;
+ if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) {
+ return 0;
+ }
// h-m-s-MM-DD-YY
- if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
- return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
+ if (!isset($rr[5])) {
+ return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
+ }
+ return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
}
/**
@@ -2600,58 +2754,63 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* Format database date based on user defined format.
*
- * @param v is the character date in YYYY-MM-DD format, returned by database
- * @param fmt is the format to apply to it, using date()
+ * @param v is the character date in YYYY-MM-DD format, returned by database
+ * @param fmt is the format to apply to it, using date()
*
* @return a date formated as user desires
*/
-
- function UserDate($v,$fmt='Y-m-d',$gmt=false)
- {
+ function UserDate($v,$fmt='Y-m-d',$gmt=false) {
$tt = $this->UnixDate($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
- if (($tt === false || $tt == -1) && $v != false) return $v;
- else if ($tt == 0) return $this->emptyDate;
- else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
+ if (($tt === false || $tt == -1) && $v != false) {
+ return $v;
+ } else if ($tt == 0) {
+ return $this->emptyDate;
+ } else if ($tt == -1) {
+ // pre-TIMESTAMP_FIRST_YEAR
}
return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
}
- /**
+ /**
*
- * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format
- * @param fmt is the format to apply to it, using date()
+ * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format
+ * @param fmt is the format to apply to it, using date()
*
* @return a timestamp formated as user desires
*/
- function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false)
- {
- if (!isset($v)) return $this->emptyTimeStamp;
+ function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false) {
+ if (!isset($v)) {
+ return $this->emptyTimeStamp;
+ }
# strlen(14) allows YYYYMMDDHHMMSS format
- if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
+ if (is_numeric($v) && strlen($v)<14) {
+ return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
+ }
$tt = $this->UnixTimeStamp($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
- if (($tt === false || $tt == -1) && $v != false) return $v;
- if ($tt == 0) return $this->emptyTimeStamp;
+ if (($tt === false || $tt == -1) && $v != false) {
+ return $v;
+ }
+ if ($tt == 0) {
+ return $this->emptyTimeStamp;
+ }
return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
}
- function escape($s,$magic_quotes=false)
- {
+ function escape($s,$magic_quotes=false) {
return $this->addq($s,$magic_quotes);
}
/**
* Quotes a string, without prefixing nor appending quotes.
*/
- function addq($s,$magic_quotes=false)
- {
+ function addq($s,$magic_quotes=false) {
if (!$magic_quotes) {
-
- if ($this->replaceQuote[0] == '\\'){
+ if ($this->replaceQuote[0] == '\\') {
// only since php 4.0.5
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
//$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
@@ -2662,9 +2821,11 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
// undo magic quotes for "
$s = str_replace('\\"','"',$s);
- if ($this->replaceQuote == "\\'" || ini_get('magic_quotes_sybase')) // ' already quoted, no need to change anything
+ if ($this->replaceQuote == "\\'" || ini_get('magic_quotes_sybase')) {
+ // ' already quoted, no need to change anything
return $s;
- else {// change \' to '' for sybase/mssql
+ } else {
+ // change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
return str_replace("\\'",$this->replaceQuote,$s);
}
@@ -2681,10 +2842,8 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return quoted string to be sent back to database
*/
- function qstr($s,$magic_quotes=false)
- {
+ function qstr($s,$magic_quotes=false) {
if (!$magic_quotes) {
-
if ($this->replaceQuote[0] == '\\'){
// only since php 4.0.5
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
@@ -2696,9 +2855,11 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
// undo magic quotes for "
$s = str_replace('\\"','"',$s);
- if ($this->replaceQuote == "\\'" || ini_get('magic_quotes_sybase')) // ' already quoted, no need to change anything
+ if ($this->replaceQuote == "\\'" || ini_get('magic_quotes_sybase')) {
+ // ' already quoted, no need to change anything
return "'$s'";
- else {// change \' to '' for sybase/mssql
+ } else {
+ // change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
}
@@ -2722,12 +2883,16 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* NOTE: phpLens uses a different algorithm and does not use PageExecute().
*
*/
- function PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0)
- {
+ function PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) {
global $ADODB_INCLUDED_LIB;
- if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
- if ($this->pageExecuteCountRows) $rs = _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
- else $rs = _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
+ if (empty($ADODB_INCLUDED_LIB)) {
+ include(ADODB_DIR.'/adodb-lib.inc.php');
+ }
+ if ($this->pageExecuteCountRows) {
+ $rs = _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
+ } else {
+ $rs = _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
+ }
return $rs;
}
@@ -2744,8 +2909,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* @param [inputarr] array of bind variables
* @return the recordset ($rs->databaseType == 'array')
*/
- function CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false)
- {
+ function CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false) {
/*switch($this->dataProvider) {
case 'postgres':
case 'mysql':
@@ -2776,42 +2940,33 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
class ADODB_Iterator_empty implements Iterator {
- private $rs;
+ private $rs;
- function __construct($rs)
- {
- $this->rs = $rs;
- }
- function rewind()
- {
- }
+ function __construct($rs) {
+ $this->rs = $rs;
+ }
- function valid()
- {
- return !$this->rs->EOF;
- }
+ function rewind() {}
- function key()
- {
- return false;
- }
+ function valid() {
+ return !$this->rs->EOF;
+ }
- function current()
- {
- return false;
- }
+ function key() {
+ return false;
+ }
- function next()
- {
- }
+ function current() {
+ return false;
+ }
- function __call($func, $params)
- {
+ function next() {}
+
+ function __call($func, $params) {
return call_user_func_array(array($this->rs, $func), $params);
}
- function hasMore()
- {
+ function hasMore() {
return false;
}
@@ -2829,29 +2984,80 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
var $_numOfRows = 0;
var $fields = false;
var $connection = false;
- function RowCount() {return 0;}
- function RecordCount() {return 0;}
- function PO_RecordCount(){return 0;}
- function Close(){return true;}
- function FetchRow() {return false;}
- function FieldCount(){ return 0;}
+
+ function RowCount() {
+ return 0;
+ }
+
+ function RecordCount() {
+ return 0;
+ }
+
+ function PO_RecordCount() {
+ return 0;
+ }
+
+ function Close() {
+ return true;
+ }
+
+ function FetchRow() {
+ return false;
+ }
+
+ function FieldCount() {
+ return 0;
+ }
+
function Init() {}
- function getIterator() {return new ADODB_Iterator_empty($this);}
- function GetAssoc() {return array();}
- function GetArray() {return array();}
- function GetAll() {return array();}
- function GetArrayLimit() {return array();}
- function GetRows() {return array();}
- function GetRowAssoc() {return array();}
- function MaxRecordCount() {return 0;}
- function NumRows() {return 0;}
- function NumCols() {return 0;}
+
+ function getIterator() {
+ return new ADODB_Iterator_empty($this);
+ }
+
+ function GetAssoc() {
+ return array();
+ }
+
+ function GetArray() {
+ return array();
+ }
+
+ function GetAll() {
+ return array();
+ }
+
+ function GetArrayLimit() {
+ return array();
+ }
+
+ function GetRows() {
+ return array();
+ }
+
+ function GetRowAssoc() {
+ return array();
+ }
+
+ function MaxRecordCount() {
+ return 0;
+ }
+
+ function NumRows() {
+ return 0;
+ }
+
+ function NumCols() {
+ return 0;
+ }
}
//==============================================================================================
// DATE AND TIME FUNCTIONS
//==============================================================================================
- if (!defined('ADODB_DATE_VERSION')) include(ADODB_DIR.'/adodb-time.inc.php');
+ if (!defined('ADODB_DATE_VERSION')) {
+ include(ADODB_DIR.'/adodb-time.inc.php');
+ }
//==============================================================================================
// CLASS ADORecordSet
@@ -2859,52 +3065,43 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
class ADODB_Iterator implements Iterator {
- private $rs;
+ private $rs;
- function __construct($rs)
- {
- $this->rs = $rs;
- }
- function rewind()
- {
- $this->rs->MoveFirst();
- }
+ function __construct($rs) {
+ $this->rs = $rs;
+ }
- function valid()
- {
- return !$this->rs->EOF;
- }
+ function rewind() {
+ $this->rs->MoveFirst();
+ }
- function key()
- {
- return $this->rs->_currentRow;
- }
+ function valid() {
+ return !$this->rs->EOF;
+ }
- function current()
- {
- return $this->rs->fields;
- }
+ function key() {
+ return $this->rs->_currentRow;
+ }
- function next()
- {
- $this->rs->MoveNext();
- }
+ function current() {
+ return $this->rs->fields;
+ }
- function __call($func, $params)
- {
- return call_user_func_array(array($this->rs, $func), $params);
+ function next() {
+ $this->rs->MoveNext();
}
+ function __call($func, $params) {
+ return call_user_func_array(array($this->rs, $func), $params);
+ }
- function hasMore()
- {
+ function hasMore() {
return !$this->rs->EOF;
}
}
-
/**
* RecordSet class that represents the dataset returned by the database.
* To keep memory overhead low, this class holds only the current row in memory.
@@ -2912,35 +3109,37 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* means recordcount not known).
*/
class ADORecordSet implements IteratorAggregate {
- /*
+
+ /**
* public variables
*/
var $dataProvider = "native";
- var $fields = false; /// holds the current row data
- var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob
+ var $fields = false; /// holds the current row data
+ var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob
/// in other words, we use a text area for editing.
- var $canSeek = false; /// indicates that seek is supported
- var $sql; /// sql text
+ var $canSeek = false; /// indicates that seek is supported
+ var $sql; /// sql text
var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object.
var $emptyTimeStamp = '&nbsp;'; /// what to display when $time==0
var $emptyDate = '&nbsp;'; /// what to display when $time==0
var $debug = false;
- var $timeCreated=0; /// datetime in Unix format rs created -- for cached recordsets
+ var $timeCreated=0; /// datetime in Unix format rs created -- for cached recordsets
- var $bind = false; /// used by Fields() to hold array - should be private?
+ var $bind = false; /// used by Fields() to hold array - should be private?
var $fetchMode; /// default fetch mode
var $connection = false; /// the parent connection
- /*
+
+ /**
* private variables
*/
var $_numOfRows = -1; /** number of rows, or -1 */
var $_numOfFields = -1; /** number of fields in recordset */
var $_queryID = -1; /** This variable keeps the result link identifier. */
var $_currentRow = -1; /** This variable keeps the current row in the Recordset. */
- var $_closed = false; /** has recordset been closed */
- var $_inited = false; /** Init() should only be called once */
- var $_obj; /** Used by FetchObj */
+ var $_closed = false; /** has recordset been closed */
+ var $_inited = false; /** Init() should only be called once */
+ var $_obj; /** Used by FetchObj */
var $_names; /** Used by FetchObj */
var $_currentPage = -1; /** Added by Iván Oliva to implement recordset pagination */
@@ -2953,38 +3152,35 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/**
* Constructor
*
- * @param queryID this is the queryID returned by ADOConnection->_query()
+ * @param queryID this is the queryID returned by ADOConnection->_query()
*
*/
- function ADORecordSet($queryID)
- {
+ function ADORecordSet($queryID) {
$this->_queryID = $queryID;
}
- function getIterator()
- {
+ function getIterator() {
return new ADODB_Iterator($this);
}
/* this is experimental - i don't really know what to return... */
- function __toString()
- {
+ function __toString() {
include_once(ADODB_DIR.'/toexport.inc.php');
return _adodb_export($this,',',',',false,true);
}
-
- function Init()
- {
- if ($this->_inited) return;
+ function Init() {
+ if ($this->_inited) {
+ return;
+ }
$this->_inited = true;
- if ($this->_queryID) @$this->_initrs();
- else {
+ if ($this->_queryID) {
+ @$this->_initrs();
+ } else {
$this->_numOfRows = 0;
$this->_numOfFields = 0;
}
if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) {
-
$this->_currentRow = 0;
if ($this->EOF = ($this->_fetch() === false)) {
$this->_numOfRows = 0; // _numOfRows could be -1
@@ -3001,7 +3197,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* the text to display to the user, and 2nd col as the return value. Default
* strings are compared with the FIRST column.
*
- * @param name name of SELECT tag
+ * @param name name of SELECT tag
* @param [defstr] the value to hilite. Use an array for multiple hilites for listbox.
* @param [blank1stItem] true to leave the 1st item in list empty
* @param [multiple] true for listbox, false for popup
@@ -3019,7 +3215,9 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$size=0, $selectAttr='',$compareFields0=true)
{
global $ADODB_INCLUDED_LIB;
- if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
+ if (empty($ADODB_INCLUDED_LIB)) {
+ include(ADODB_DIR.'/adodb-lib.inc.php');
+ }
return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple,
$size, $selectAttr,$compareFields0);
}
@@ -3033,8 +3231,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* strings are compared with the SECOND column.
*
*/
- function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='')
- {
+ function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='') {
return $this->GetMenu($name,$defstr,$blank1stItem,$multiple,
$size, $selectAttr,false);
}
@@ -3046,7 +3243,9 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$size=0, $selectAttr='')
{
global $ADODB_INCLUDED_LIB;
- if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
+ if (empty($ADODB_INCLUDED_LIB)) {
+ include(ADODB_DIR.'/adodb-lib.inc.php');
+ }
return _adodb_getmenu_gp($this, $name,$defstr,$blank1stItem,$multiple,
$size, $selectAttr,false);
}
@@ -3058,8 +3257,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return an array indexed by the rows (0-based) from the recordset
*/
- function GetArray($nRows = -1)
- {
+ function GetArray($nRows = -1) {
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) {
$results = adodb_getall($this,$nRows);
return $results;
@@ -3074,8 +3272,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
return $results;
}
- function GetAll($nRows = -1)
- {
+ function GetAll($nRows = -1) {
$arr = $this->GetArray($nRows);
return $arr;
}
@@ -3084,8 +3281,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* Some databases allow multiple recordsets to be returned. This function
* will return true if there is a next recordset, or false if no more.
*/
- function NextRecordSet()
- {
+ function NextRecordSet() {
return false;
}
@@ -3098,8 +3294,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return an array indexed by the rows (0-based) from the recordset
*/
- function GetArrayLimit($nrows,$offset=-1)
- {
+ function GetArrayLimit($nrows,$offset=-1) {
if ($offset <= 0) {
$arr = $this->GetArray($nrows);
return $arr;
@@ -3125,8 +3320,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return an array indexed by the rows (0-based) from the recordset
*/
- function GetRows($nRows = -1)
- {
+ function GetRows($nRows = -1) {
$arr = $this->GetArray($nRows);
return $arr;
}
@@ -3138,17 +3332,16 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* $force_array == true.
*
* @param [force_array] has only meaning if we have 2 data columns. If false, a 1 dimensional
- * array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing,
- * read the source.
+ * array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing,
+ * read the source.
*
* @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and
* instead of returning array[col0] => array(remaining cols), return array[col0] => col1
*
* @return an associative array indexed by the first column of the array,
- * or false if the data has less than 2 cols.
+ * or false if the data has less than 2 cols.
*/
- function GetAssoc($force_array = false, $first2cols = false)
- {
+ function GetAssoc($force_array = false, $first2cols = false) {
global $ADODB_EXTENSION;
$cols = $this->_numOfFields;
@@ -3244,35 +3437,42 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/**
*
- * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format
- * @param fmt is the format to apply to it, using date()
+ * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format
+ * @param fmt is the format to apply to it, using date()
*
* @return a timestamp formated as user desires
*/
- function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
- {
- if (is_numeric($v) && strlen($v)<14) return adodb_date($fmt,$v);
+ function UserTimeStamp($v,$fmt='Y-m-d H:i:s') {
+ if (is_numeric($v) && strlen($v)<14) {
+ return adodb_date($fmt,$v);
+ }
$tt = $this->UnixTimeStamp($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
- if (($tt === false || $tt == -1) && $v != false) return $v;
- if ($tt === 0) return $this->emptyTimeStamp;
+ if (($tt === false || $tt == -1) && $v != false) {
+ return $v;
+ }
+ if ($tt === 0) {
+ return $this->emptyTimeStamp;
+ }
return adodb_date($fmt,$tt);
}
/**
- * @param v is the character date in YYYY-MM-DD format, returned by database
- * @param fmt is the format to apply to it, using date()
+ * @param v is the character date in YYYY-MM-DD format, returned by database
+ * @param fmt is the format to apply to it, using date()
*
* @return a date formated as user desires
*/
- function UserDate($v,$fmt='Y-m-d')
- {
+ function UserDate($v,$fmt='Y-m-d') {
$tt = $this->UnixDate($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
- if (($tt === false || $tt == -1) && $v != false) return $v;
- else if ($tt == 0) return $this->emptyDate;
- else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
+ if (($tt === false || $tt == -1) && $v != false) {
+ return $v;
+ } else if ($tt == 0) {
+ return $this->emptyDate;
+ } else if ($tt == -1) {
+ // pre-TIMESTAMP_FIRST_YEAR
}
return adodb_date($fmt,$tt);
}
@@ -3283,8 +3483,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/
- static function UnixDate($v)
- {
+ static function UnixDate($v) {
return ADOConnection::UnixDate($v);
}
@@ -3294,8 +3493,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/
- static function UnixTimeStamp($v)
- {
+ static function UnixTimeStamp($v) {
return ADOConnection::UnixTimeStamp($v);
}
@@ -3303,8 +3501,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/**
* PEAR DB Compat - do not use internally
*/
- function Free()
- {
+ function Free() {
return $this->Close();
}
@@ -3312,8 +3509,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/**
* PEAR DB compat, number of rows
*/
- function NumRows()
- {
+ function NumRows() {
return $this->_numOfRows;
}
@@ -3321,8 +3517,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/**
* PEAR DB compat, number of cols
*/
- function NumCols()
- {
+ function NumCols() {
return $this->_numOfFields;
}
@@ -3332,14 +3527,15 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return false or array containing the current record
*/
- function FetchRow()
- {
+ function FetchRow() {
if ($this->EOF) {
return false;
}
$arr = $this->fields;
$this->_currentRow++;
- if (!$this->_fetch()) $this->EOF = true;
+ if (!$this->_fetch()) {
+ $this->EOF = true;
+ }
return $arr;
}
@@ -3350,9 +3546,10 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return DB_OK or error object
*/
- function FetchInto(&$arr)
- {
- if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
+ function FetchInto(&$arr) {
+ if ($this->EOF) {
+ return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
+ }
$arr = $this->fields;
$this->MoveNext();
return 1; // DB_OK
@@ -3364,9 +3561,10 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return true or false
*/
- function MoveFirst()
- {
- if ($this->_currentRow == 0) return true;
+ function MoveFirst() {
+ if ($this->_currentRow == 0) {
+ return true;
+ }
return $this->Move(0);
}
@@ -3376,10 +3574,13 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return true or false
*/
- function MoveLast()
- {
- if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1);
- if ($this->EOF) return false;
+ function MoveLast() {
+ if ($this->_numOfRows >= 0) {
+ return $this->Move($this->_numOfRows-1);
+ }
+ if ($this->EOF) {
+ return false;
+ }
while (!$this->EOF) {
$f = $this->fields;
$this->MoveNext();
@@ -3395,11 +3596,12 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return true if there still rows available, or false if there are no more rows (EOF).
*/
- function MoveNext()
- {
+ function MoveNext() {
if (!$this->EOF) {
$this->_currentRow++;
- if ($this->_fetch()) return true;
+ if ($this->_fetch()) {
+ return true;
+ }
}
$this->EOF = true;
/* -- tested error handling when scrolling cursor -- seems useless.
@@ -3421,15 +3623,18 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return true if there still rows available, or false if there are no more rows (EOF).
*/
- function Move($rowNumber = 0)
- {
+ function Move($rowNumber = 0) {
$this->EOF = false;
- if ($rowNumber == $this->_currentRow) return true;
- if ($rowNumber >= $this->_numOfRows)
- if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2;
+ if ($rowNumber == $this->_currentRow) {
+ return true;
+ }
+ if ($rowNumber >= $this->_numOfRows) {
+ if ($this->_numOfRows != -1) {
+ $rowNumber = $this->_numOfRows-2;
+ }
+ }
if ($this->canSeek) {
-
if ($this->_seek($rowNumber)) {
$this->_currentRow = $rowNumber;
if ($this->_fetch()) {
@@ -3440,18 +3645,21 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
return false;
}
} else {
- if ($rowNumber < $this->_currentRow) return false;
+ if ($rowNumber < $this->_currentRow) {
+ return false;
+ }
global $ADODB_EXTENSION;
if ($ADODB_EXTENSION) {
while (!$this->EOF && $this->_currentRow < $rowNumber) {
adodb_movenext($this);
}
} else {
-
while (! $this->EOF && $this->_currentRow < $rowNumber) {
$this->_currentRow++;
- if (!$this->_fetch()) $this->EOF = true;
+ if (!$this->_fetch()) {
+ $this->EOF = true;
+ }
}
}
return !($this->EOF);
@@ -3471,8 +3679,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return the value of $colname column
*/
- function Fields($colname)
- {
+ function Fields($colname) {
return $this->fields[$colname];
}
@@ -3482,8 +3689,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* @param int $upper Case for the array keys, defaults to uppercase
* (see ADODB_ASSOC_CASE_xxx constants)
*/
- function GetAssocKeys($upper=ADODB_ASSOC_CASE_UPPER)
- {
+ function GetAssocKeys($upper=ADODB_ASSOC_CASE_UPPER) {
$this->bind = array();
for ($i=0; $i < $this->_numOfFields; $i++) {
$o = $this->FetchField($i);
@@ -3511,8 +3717,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* @param int $upper Case for the array keys, defaults to uppercase
* (see ADODB_ASSOC_CASE_xxx constants)
*/
- function GetRowAssoc($upper=ADODB_ASSOC_CASE_UPPER)
- {
+ function GetRowAssoc($upper=ADODB_ASSOC_CASE_UPPER) {
$record = array();
if (!$this->bind) {
$this->GetAssocKeys($upper);
@@ -3535,8 +3740,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return true or false
*/
- function Close()
- {
+ function Close() {
// free connection object - this seems to globally free the object
// and not merely the reference, so don't do this...
// $this->connection = false;
@@ -3552,15 +3756,16 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return the number of rows or -1 if this is not supported
*/
- function RecordCount() {return $this->_numOfRows;}
+ function RecordCount() {
+ return $this->_numOfRows;
+ }
/*
* If we are using PageExecute(), this will return the maximum possible rows
* that can be returned when paging a recordset.
*/
- function MaxRecordCount()
- {
+ function MaxRecordCount() {
return ($this->_maxRecordCount) ? $this->_maxRecordCount : $this->RecordCount();
}
@@ -3569,7 +3774,9 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return the number of rows or -1 if this is not supported
*/
- function RowCount() {return $this->_numOfRows;}
+ function RowCount() {
+ return $this->_numOfRows;
+ }
/**
@@ -3586,9 +3793,13 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
// the database doesn't support native recordcount, so we do a workaround
if ($lnumrows == -1 && $this->connection) {
IF ($table) {
- if ($condition) $condition = " WHERE " . $condition;
+ if ($condition) {
+ $condition = " WHERE " . $condition;
+ }
$resultrows = $this->connection->Execute("SELECT COUNT(*) FROM $table $condition");
- if ($resultrows) $lnumrows = reset($resultrows->fields);
+ if ($resultrows) {
+ $lnumrows = reset($resultrows->fields);
+ }
}
}
return $lnumrows;
@@ -3598,20 +3809,26 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/**
* @return the current row in the recordset. If at EOF, will return the last row. 0-based.
*/
- function CurrentRow() {return $this->_currentRow;}
+ function CurrentRow() {
+ return $this->_currentRow;
+ }
/**
* synonym for CurrentRow -- for ADO compat
*
* @return the current row in the recordset. If at EOF, will return the last row. 0-based.
*/
- function AbsolutePosition() {return $this->_currentRow;}
+ function AbsolutePosition() {
+ return $this->_currentRow;
+ }
/**
* @return the number of columns in the recordset. Some databases will set this to 0
* if no records are returned, others will return the number of columns in the query.
*/
- function FieldCount() {return $this->_numOfFields;}
+ function FieldCount() {
+ return $this->_numOfFields;
+ }
/**
@@ -3621,8 +3838,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return the ADOFieldObject for that column, or false.
*/
- function FetchField($fieldoffset = -1)
- {
+ function FetchField($fieldoffset = -1) {
// must be defined by child class
return false;
@@ -3632,8 +3848,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* Get the ADOFieldObjects of all columns in an array.
*
*/
- function FieldTypesArray()
- {
+ function FieldTypesArray() {
$arr = array();
for ($i=0, $max=$this->_numOfFields; $i < $max; $i++)
$arr[] = $this->FetchField($i);
@@ -3646,8 +3861,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return the object with the properties set to the fields of the current row
*/
- function FetchObj()
- {
+ function FetchObj() {
$o = $this->FetchObject(false);
return $o;
}
@@ -3660,8 +3874,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @return the object with the properties set to the fields of the current row
*/
- function FetchObject($isupper=true)
- {
+ function FetchObject($isupper=true) {
if (empty($this->_obj)) {
$this->_obj = new ADOFetchObj();
$this->_names = array();
@@ -3671,13 +3884,19 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
}
}
$i = 0;
- if (PHP_VERSION >= 5) $o = clone($this->_obj);
- else $o = $this->_obj;
+ if (PHP_VERSION >= 5) {
+ $o = clone($this->_obj);
+ } else {
+ $o = $this->_obj;
+ }
for ($i=0; $i <$this->_numOfFields; $i++) {
$name = $this->_names[$i];
- if ($isupper) $n = strtoupper($name);
- else $n = $name;
+ if ($isupper) {
+ $n = strtoupper($name);
+ } else {
+ $n = $name;
+ }
$o->$n = $this->Fields($name);
}
@@ -3689,12 +3908,11 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* The default is lower-case field names.
*
* @return the object with the properties set to the fields of the current row,
- * or false if EOF
+ * or false if EOF
*
* Fixed bug reported by tim@orotech.net
*/
- function FetchNextObj()
- {
+ function FetchNextObj() {
$o = $this->FetchNextObject(false);
return $o;
}
@@ -3707,17 +3925,18 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* @param $isupper to set the object property names to uppercase
*
* @return the object with the properties set to the fields of the current row,
- * or false if EOF
+ * or false if EOF
*
* Fixed bug reported by tim@orotech.net
*/
- function FetchNextObject($isupper=true)
- {
+ function FetchNextObject($isupper=true) {
$o = false;
if ($this->_numOfRows != 0 && !$this->EOF) {
$o = $this->FetchObject($isupper);
$this->_currentRow++;
- if ($this->_fetch()) return $o;
+ if ($this->_fetch()) {
+ return $o;
+ }
}
$this->EOF = true;
return $o;
@@ -3730,7 +3949,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @param t is the type passed in. Normally is ADOFieldObject->type.
* @param len is the maximum length of that field. This is because we treat character
- * fields bigger than a certain size as a 'B' (blob).
+ * fields bigger than a certain size as a 'B' (blob).
* @param fieldobj is the field object returned by the database driver. Can hold
* additional info (eg. primary_key for mysql).
*
@@ -3738,160 +3957,168 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* C for character < 250 chars
* X for teXt (>= 250 chars)
* B for Binary
- * N for numeric or floating point
+ * N for numeric or floating point
* D for date
* T for timestamp
- * L for logical/Boolean
+ * L for logical/Boolean
* I for integer
* R for autoincrement counter/integer
*
*
*/
- function MetaType($t,$len=-1,$fieldobj=false)
- {
+ function MetaType($t,$len=-1,$fieldobj=false) {
if (is_object($t)) {
$fieldobj = $t;
$t = $fieldobj->type;
$len = $fieldobj->max_length;
}
- // changed in 2.32 to hashing instead of switch stmt for speed...
- static $typeMap = array(
- 'VARCHAR' => 'C',
- 'VARCHAR2' => 'C',
- 'CHAR' => 'C',
- 'C' => 'C',
- 'STRING' => 'C',
- 'NCHAR' => 'C',
- 'NVARCHAR' => 'C',
- 'VARYING' => 'C',
- 'BPCHAR' => 'C',
- 'CHARACTER' => 'C',
- 'INTERVAL' => 'C', # Postgres
- 'MACADDR' => 'C', # postgres
- 'VAR_STRING' => 'C', # mysql
- ##
- 'LONGCHAR' => 'X',
- 'TEXT' => 'X',
- 'NTEXT' => 'X',
- 'M' => 'X',
- 'X' => 'X',
- 'CLOB' => 'X',
- 'NCLOB' => 'X',
- 'LVARCHAR' => 'X',
- ##
- 'BLOB' => 'B',
- 'IMAGE' => 'B',
- 'BINARY' => 'B',
- 'VARBINARY' => 'B',
- 'LONGBINARY' => 'B',
- 'B' => 'B',
- ##
- 'YEAR' => 'D', // mysql
- 'DATE' => 'D',
- 'D' => 'D',
- ##
- 'UNIQUEIDENTIFIER' => 'C', # MS SQL Server
- ##
- 'SMALLDATETIME' => 'T',
- 'TIME' => 'T',
- 'TIMESTAMP' => 'T',
- 'DATETIME' => 'T',
- 'TIMESTAMPTZ' => 'T',
- 'T' => 'T',
- 'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql
- ##
- 'BOOL' => 'L',
- 'BOOLEAN' => 'L',
- 'BIT' => 'L',
- 'L' => 'L',
- ##
- 'COUNTER' => 'R',
- 'R' => 'R',
- 'SERIAL' => 'R', // ifx
- 'INT IDENTITY' => 'R',
- ##
- 'INT' => 'I',
- 'INT2' => 'I',
- 'INT4' => 'I',
- 'INT8' => 'I',
- 'INTEGER' => 'I',
- 'INTEGER UNSIGNED' => 'I',
- 'SHORT' => 'I',
- 'TINYINT' => 'I',
- 'SMALLINT' => 'I',
- 'I' => 'I',
- ##
- 'LONG' => 'N', // interbase is numeric, oci8 is blob
- 'BIGINT' => 'N', // this is bigger than PHP 32-bit integers
- 'DECIMAL' => 'N',
- 'DEC' => 'N',
- 'REAL' => 'N',
- 'DOUBLE' => 'N',
- 'DOUBLE PRECISION' => 'N',
- 'SMALLFLOAT' => 'N',
- 'FLOAT' => 'N',
- 'NUMBER' => 'N',
- 'NUM' => 'N',
- 'NUMERIC' => 'N',
- 'MONEY' => 'N',
- ## informix 9.2
- 'SQLINT' => 'I',
- 'SQLSERIAL' => 'I',
- 'SQLSMINT' => 'I',
- 'SQLSMFLOAT' => 'N',
- 'SQLFLOAT' => 'N',
- 'SQLMONEY' => 'N',
- 'SQLDECIMAL' => 'N',
- 'SQLDATE' => 'D',
- 'SQLVCHAR' => 'C',
- 'SQLCHAR' => 'C',
- 'SQLDTIME' => 'T',
- 'SQLINTERVAL' => 'N',
- 'SQLBYTES' => 'B',
- 'SQLTEXT' => 'X',
- ## informix 10
- "SQLINT8" => 'I8',
- "SQLSERIAL8" => 'I8',
- "SQLNCHAR" => 'C',
- "SQLNVCHAR" => 'C',
- "SQLLVARCHAR" => 'X',
- "SQLBOOL" => 'L'
+ // changed in 2.32 to hashing instead of switch stmt for speed...
+ static $typeMap = array(
+ 'VARCHAR' => 'C',
+ 'VARCHAR2' => 'C',
+ 'CHAR' => 'C',
+ 'C' => 'C',
+ 'STRING' => 'C',
+ 'NCHAR' => 'C',
+ 'NVARCHAR' => 'C',
+ 'VARYING' => 'C',
+ 'BPCHAR' => 'C',
+ 'CHARACTER' => 'C',
+ 'INTERVAL' => 'C', # Postgres
+ 'MACADDR' => 'C', # postgres
+ 'VAR_STRING' => 'C', # mysql
+ ##
+ 'LONGCHAR' => 'X',
+ 'TEXT' => 'X',
+ 'NTEXT' => 'X',
+ 'M' => 'X',
+ 'X' => 'X',
+ 'CLOB' => 'X',
+ 'NCLOB' => 'X',
+ 'LVARCHAR' => 'X',
+ ##
+ 'BLOB' => 'B',
+ 'IMAGE' => 'B',
+ 'BINARY' => 'B',
+ 'VARBINARY' => 'B',
+ 'LONGBINARY' => 'B',
+ 'B' => 'B',
+ ##
+ 'YEAR' => 'D', // mysql
+ 'DATE' => 'D',
+ 'D' => 'D',
+ ##
+ 'UNIQUEIDENTIFIER' => 'C', # MS SQL Server
+ ##
+ 'SMALLDATETIME' => 'T',
+ 'TIME' => 'T',
+ 'TIMESTAMP' => 'T',
+ 'DATETIME' => 'T',
+ 'TIMESTAMPTZ' => 'T',
+ 'T' => 'T',
+ 'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql
+ ##
+ 'BOOL' => 'L',
+ 'BOOLEAN' => 'L',
+ 'BIT' => 'L',
+ 'L' => 'L',
+ ##
+ 'COUNTER' => 'R',
+ 'R' => 'R',
+ 'SERIAL' => 'R', // ifx
+ 'INT IDENTITY' => 'R',
+ ##
+ 'INT' => 'I',
+ 'INT2' => 'I',
+ 'INT4' => 'I',
+ 'INT8' => 'I',
+ 'INTEGER' => 'I',
+ 'INTEGER UNSIGNED' => 'I',
+ 'SHORT' => 'I',
+ 'TINYINT' => 'I',
+ 'SMALLINT' => 'I',
+ 'I' => 'I',
+ ##
+ 'LONG' => 'N', // interbase is numeric, oci8 is blob
+ 'BIGINT' => 'N', // this is bigger than PHP 32-bit integers
+ 'DECIMAL' => 'N',
+ 'DEC' => 'N',
+ 'REAL' => 'N',
+ 'DOUBLE' => 'N',
+ 'DOUBLE PRECISION' => 'N',
+ 'SMALLFLOAT' => 'N',
+ 'FLOAT' => 'N',
+ 'NUMBER' => 'N',
+ 'NUM' => 'N',
+ 'NUMERIC' => 'N',
+ 'MONEY' => 'N',
+
+ ## informix 9.2
+ 'SQLINT' => 'I',
+ 'SQLSERIAL' => 'I',
+ 'SQLSMINT' => 'I',
+ 'SQLSMFLOAT' => 'N',
+ 'SQLFLOAT' => 'N',
+ 'SQLMONEY' => 'N',
+ 'SQLDECIMAL' => 'N',
+ 'SQLDATE' => 'D',
+ 'SQLVCHAR' => 'C',
+ 'SQLCHAR' => 'C',
+ 'SQLDTIME' => 'T',
+ 'SQLINTERVAL' => 'N',
+ 'SQLBYTES' => 'B',
+ 'SQLTEXT' => 'X',
+ ## informix 10
+ "SQLINT8" => 'I8',
+ "SQLSERIAL8" => 'I8',
+ "SQLNCHAR" => 'C',
+ "SQLNVCHAR" => 'C',
+ "SQLLVARCHAR" => 'X',
+ "SQLBOOL" => 'L'
);
$tmap = false;
$t = strtoupper($t);
$tmap = (isset($typeMap[$t])) ? $typeMap[$t] : 'N';
switch ($tmap) {
- case 'C':
-
- // is the char field is too long, return as text field...
- if ($this->blobSize >= 0) {
- if ($len > $this->blobSize) return 'X';
- } else if ($len > 250) {
- return 'X';
- }
- return 'C';
+ case 'C':
+ // is the char field is too long, return as text field...
+ if ($this->blobSize >= 0) {
+ if ($len > $this->blobSize) {
+ return 'X';
+ }
+ } else if ($len > 250) {
+ return 'X';
+ }
+ return 'C';
- case 'I':
- if (!empty($fieldobj->primary_key)) return 'R';
- return 'I';
+ case 'I':
+ if (!empty($fieldobj->primary_key)) {
+ return 'R';
+ }
+ return 'I';
- case false:
- return 'N';
+ case false:
+ return 'N';
- case 'B':
- if (isset($fieldobj->binary))
- return ($fieldobj->binary) ? 'B' : 'X';
- return 'B';
+ case 'B':
+ if (isset($fieldobj->binary)) {
+ return ($fieldobj->binary) ? 'B' : 'X';
+ }
+ return 'B';
- case 'D':
- if (!empty($this->connection) && !empty($this->connection->datetime)) return 'T';
- return 'D';
+ case 'D':
+ if (!empty($this->connection) && !empty($this->connection->datetime)) {
+ return 'T';
+ }
+ return 'D';
- default:
- if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B';
- return $tmap;
+ default:
+ if ($t == 'LONG' && $this->dataProvider == 'oci8') {
+ return 'B';
+ }
+ return $tmap;
}
}
@@ -3901,33 +4128,37 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/**
* set/returns the current recordset page when paginating
*/
- function AbsolutePage($page=-1)
- {
- if ($page != -1) $this->_currentPage = $page;
+ function AbsolutePage($page=-1) {
+ if ($page != -1) {
+ $this->_currentPage = $page;
+ }
return $this->_currentPage;
}
/**
* set/returns the status of the atFirstPage flag when paginating
*/
- function AtFirstPage($status=false)
- {
- if ($status != false) $this->_atFirstPage = $status;
+ function AtFirstPage($status=false) {
+ if ($status != false) {
+ $this->_atFirstPage = $status;
+ }
return $this->_atFirstPage;
}
- function LastPageNo($page = false)
- {
- if ($page != false) $this->_lastPageNo = $page;
+ function LastPageNo($page = false) {
+ if ($page != false) {
+ $this->_lastPageNo = $page;
+ }
return $this->_lastPageNo;
}
/**
* set/returns the status of the atLastPage flag when paginating
*/
- function AtLastPage($status=false)
- {
- if ($status != false) $this->_atLastPage = $status;
+ function AtLastPage($status=false) {
+ if ($status != false) {
+ $this->_atLastPage = $status;
+ }
return $this->_atLastPage;
}
@@ -3943,12 +4174,11 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* Note that the constructor is different from the standard ADORecordSet
*/
-
class ADORecordSet_array extends ADORecordSet
{
var $databaseType = 'array';
- var $_array; // holds the 2-dimensional data array
+ var $_array; // holds the 2-dimensional data array
var $_types; // the array of types of each column (C B I L M)
var $_colnames; // names of each column in array
var $_skiprow1; // skip 1st row because it holds column names
@@ -3958,12 +4188,11 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
var $insertid = false;
var $sql = '';
var $compat = false;
+
/**
* Constructor
- *
*/
- function ADORecordSet_array($fakeid=1)
- {
+ function ADORecordSet_array($fakeid=1) {
global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH;
// fetch() on EOF does not delete $this->fields
@@ -3972,11 +4201,12 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$this->fetchMode = $ADODB_FETCH_MODE;
}
- function _transpose($addfieldnames=true)
- {
+ function _transpose($addfieldnames=true) {
global $ADODB_INCLUDED_LIB;
- if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
+ if (empty($ADODB_INCLUDED_LIB)) {
+ include(ADODB_DIR.'/adodb-lib.inc.php');
+ }
$hdr = true;
$fobjs = $addfieldnames ? $this->_fieldobjects : false;
@@ -4015,14 +4245,13 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* @param [colnames] array of column names. If set, then the first row of
* $array should not hold the column names.
*/
- function InitArray($array,$typearr,$colnames=false)
- {
+ function InitArray($array,$typearr,$colnames=false) {
$this->_array = $array;
$this->_types = $typearr;
if ($colnames) {
$this->_skiprow1 = false;
$this->_colnames = $colnames;
- } else {
+ } else {
$this->_skiprow1 = true;
$this->_colnames = $array[0];
}
@@ -4036,8 +4265,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* unless paramter $colnames is used.
* @param fieldarr holds an array of ADOFieldObject's.
*/
- function InitArrayFields(&$array,&$fieldarr)
- {
+ function InitArrayFields(&$array,&$fieldarr) {
$this->_array = $array;
$this->_skiprow1= false;
if ($fieldarr) {
@@ -4046,8 +4274,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$this->Init();
}
- function GetArray($nRows=-1)
- {
+ function GetArray($nRows=-1) {
if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) {
return $this->_array;
} else {
@@ -4056,22 +4283,25 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
}
}
- function _initrs()
- {
+ function _initrs() {
$this->_numOfRows = sizeof($this->_array);
- if ($this->_skiprow1) $this->_numOfRows -= 1;
+ if ($this->_skiprow1) {
+ $this->_numOfRows -= 1;
+ }
- $this->_numOfFields =(isset($this->_fieldobjects)) ?
- sizeof($this->_fieldobjects):sizeof($this->_types);
+ $this->_numOfFields = (isset($this->_fieldobjects))
+ ? sizeof($this->_fieldobjects)
+ : sizeof($this->_types);
}
/* Use associative array to get fields array */
- function Fields($colname)
- {
+ function Fields($colname) {
$mode = isset($this->adodbFetchMode) ? $this->adodbFetchMode : $this->fetchMode;
if ($mode & ADODB_FETCH_ASSOC) {
- if (!isset($this->fields[$colname]) && !is_null($this->fields[$colname])) $colname = strtolower($colname);
+ if (!isset($this->fields[$colname]) && !is_null($this->fields[$colname])) {
+ $colname = strtolower($colname);
+ }
return $this->fields[$colname];
}
if (!$this->bind) {
@@ -4084,8 +4314,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
return $this->fields[$this->bind[strtoupper($colname)]];
}
- function FetchField($fieldOffset = -1)
- {
+ function FetchField($fieldOffset = -1) {
if (isset($this->_fieldobjects)) {
return $this->_fieldobjects[$fieldOffset];
}
@@ -4097,28 +4326,32 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
return $o;
}
- function _seek($row)
- {
+ function _seek($row) {
if (sizeof($this->_array) && 0 <= $row && $row < $this->_numOfRows) {
$this->_currentRow = $row;
- if ($this->_skiprow1) $row += 1;
+ if ($this->_skiprow1) {
+ $row += 1;
+ }
$this->fields = $this->_array[$row];
return true;
}
return false;
}
- function MoveNext()
- {
+ function MoveNext() {
if (!$this->EOF) {
$this->_currentRow++;
$pos = $this->_currentRow;
if ($this->_numOfRows <= $pos) {
- if (!$this->compat) $this->fields = false;
+ if (!$this->compat) {
+ $this->fields = false;
+ }
} else {
- if ($this->_skiprow1) $pos += 1;
+ if ($this->_skiprow1) {
+ $pos += 1;
+ }
$this->fields = $this->_array[$pos];
return true;
}
@@ -4128,21 +4361,23 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
return false;
}
- function _fetch()
- {
+ function _fetch() {
$pos = $this->_currentRow;
if ($this->_numOfRows <= $pos) {
- if (!$this->compat) $this->fields = false;
+ if (!$this->compat) {
+ $this->fields = false;
+ }
return false;
}
- if ($this->_skiprow1) $pos += 1;
+ if ($this->_skiprow1) {
+ $pos += 1;
+ }
$this->fields = $this->_array[$pos];
return true;
}
- function _close()
- {
+ function _close() {
return true;
}
@@ -4157,23 +4392,25 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*
* @deprecated
*/
- function ADOLoadDB($dbType)
- {
+ function ADOLoadDB($dbType) {
return ADOLoadCode($dbType);
}
/**
* Load the code for a specific database driver. Private function. Do not use.
*/
- function ADOLoadCode($dbType)
- {
+ function ADOLoadCode($dbType) {
global $ADODB_LASTDB;
- if (!$dbType) return false;
+ if (!$dbType) {
+ return false;
+ }
$db = strtolower($dbType);
switch ($db) {
case 'ado':
- if (PHP_VERSION >= 5) $db = 'ado5';
+ if (PHP_VERSION >= 5) {
+ $db = 'ado5';
+ }
$class = 'ado';
break;
@@ -4194,19 +4431,23 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$file = ADODB_DIR."/drivers/adodb-".$db.".inc.php";
@include_once($file);
$ADODB_LASTDB = $class;
- if (class_exists("ADODB_" . $class)) return $class;
+ if (class_exists("ADODB_" . $class)) {
+ return $class;
+ }
//ADOConnection::outp(adodb_pr(get_declared_classes(),true));
- if (!file_exists($file)) ADOConnection::outp("Missing file: $file");
- else ADOConnection::outp("Syntax error in file: $file");
+ if (!file_exists($file)) {
+ ADOConnection::outp("Missing file: $file");
+ } else {
+ ADOConnection::outp("Syntax error in file: $file");
+ }
return false;
}
/**
* synonym for ADONewConnection for people like me who cannot remember the correct name
*/
- function NewADOConnection($db='')
- {
+ function NewADOConnection($db='') {
$tmp = ADONewConnection($db);
return $tmp;
}
@@ -4215,15 +4456,16 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* Instantiate a new Connection class for a specific database driver.
*
* @param [db] is the database Connection object to create. If undefined,
- * use the last database driver that was loaded by ADOLoadCode().
+ * use the last database driver that was loaded by ADOLoadCode().
*
* @return the freshly created instance of the Connection class.
*/
- function ADONewConnection($db='')
- {
+ function ADONewConnection($db='') {
global $ADODB_NEWCONNECTION, $ADODB_LASTDB;
- if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
+ if (!defined('ADODB_ASSOC_CASE')) {
+ define('ADODB_ASSOC_CASE',2);
+ }
$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
if (($at = strpos($db,'://')) !== FALSE) {
$origdsn = $db;
@@ -4259,12 +4501,12 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
if (strncmp($origdsn,'pdo',3) == 0) {
$sch = explode('_',$dsna['scheme']);
if (sizeof($sch)>1) {
-
$dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
- if ($sch[1] == 'sqlite')
+ if ($sch[1] == 'sqlite') {
$dsna['host'] = rawurlencode($sch[1].':'.rawurldecode($dsna['host']));
- else
+ } else {
$dsna['host'] = rawurlencode($sch[1].':host='.rawurldecode($dsna['host']));
+ }
$dsna['scheme'] = 'pdo';
}
}
@@ -4284,7 +4526,9 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$arr = explode('=',$v);
$opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
}
- } else $opt = array();
+ } else {
+ $opt = array();
+ }
}
/*
* phptype: Database backend used in PHP (mysql, odbc etc.)
@@ -4302,22 +4546,29 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
if(empty($obj)) {
- if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';
- if (empty($db)) $db = $ADODB_LASTDB;
-
- if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);
+ if (!isset($ADODB_LASTDB)) {
+ $ADODB_LASTDB = '';
+ }
+ if (empty($db)) {
+ $db = $ADODB_LASTDB;
+ }
+ if ($db != $ADODB_LASTDB) {
+ $db = ADOLoadCode($db);
+ }
if (!$db) {
- if (isset($origdsn)) $db = $origdsn;
+ if (isset($origdsn)) {
+ $db = $origdsn;
+ }
if ($errorfn) {
// raise an error
$ignore = false;
$errorfn('ADONewConnection', 'ADONewConnection', -998,
- "could not load the database driver for '$db'",
- $db,false,$ignore);
- } else
- ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);
-
+ "could not load the database driver for '$db'",
+ $db,false,$ignore);
+ } else {
+ ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);
+ }
return false;
}
@@ -4332,19 +4583,23 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
# constructor should not fail
if ($obj) {
- if ($errorfn) $obj->raiseErrorFn = $errorfn;
+ if ($errorfn) {
+ $obj->raiseErrorFn = $errorfn;
+ }
if (isset($dsna)) {
- if (isset($dsna['port'])) $obj->port = $dsna['port'];
+ if (isset($dsna['port'])) {
+ $obj->port = $dsna['port'];
+ }
foreach($opt as $k => $v) {
switch(strtolower($k)) {
case 'new':
$nconnect = true; $persist = true; break;
case 'persist':
- case 'persistent': $persist = $v; break;
+ case 'persistent': $persist = $v; break;
case 'debug': $obj->debug = (integer) $v; break;
#ibase
case 'role': $obj->role = $v; break;
- case 'dialect': $obj->dialect = (integer) $v; break;
+ case 'dialect': $obj->dialect = (integer) $v; break;
case 'charset': $obj->charset = $v; $obj->charSet=$v; break;
case 'buffers': $obj->buffers = $v; break;
case 'fetchmode': $obj->SetFetchMode($v); break;
@@ -4362,22 +4617,29 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
case 'memcache':
$varr = explode(':',$v);
$vlen = sizeof($varr);
- if ($vlen == 0) break;
+ if ($vlen == 0) {
+ break;
+ }
$obj->memCache = true;
$obj->memCacheHost = explode(',',$varr[0]);
- if ($vlen == 1) break;
+ if ($vlen == 1) {
+ break;
+ }
$obj->memCachePort = $varr[1];
- if ($vlen == 2) break;
+ if ($vlen == 2) {
+ break;
+ }
$obj->memCacheCompress = $varr[2] ? true : false;
break;
}
}
- if (empty($persist))
+ if (empty($persist)) {
$ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
- else if (empty($nconnect))
+ } else if (empty($nconnect)) {
$ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
- else
+ } else {
$ok = $obj->NConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
+ }
if (!$ok) {
return false;
@@ -4390,40 +4652,57 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
// $perf == true means called by NewPerfMonitor(), otherwise for data dictionary
- function _adodb_getdriver($provider,$drivername,$perf=false)
- {
+ function _adodb_getdriver($provider,$drivername,$perf=false) {
switch ($provider) {
- case 'odbtp': if (strncmp('odbtp_',$drivername,6)==0) return substr($drivername,6);
- case 'odbc' : if (strncmp('odbc_',$drivername,5)==0) return substr($drivername,5);
- case 'ado' : if (strncmp('ado_',$drivername,4)==0) return substr($drivername,4);
- case 'native': break;
- default:
- return $provider;
+ case 'odbtp':
+ if (strncmp('odbtp_',$drivername,6)==0) {
+ return substr($drivername,6);
+ }
+ case 'odbc' :
+ if (strncmp('odbc_',$drivername,5)==0) {
+ return substr($drivername,5);
+ }
+ case 'ado' :
+ if (strncmp('ado_',$drivername,4)==0) {
+ return substr($drivername,4);
+ }
+ case 'native':
+ break;
+ default:
+ return $provider;
}
switch($drivername) {
- case 'mysqlt':
- case 'mysqli':
+ case 'mysqlt':
+ case 'mysqli':
$drivername='mysql';
break;
- case 'postgres7':
- case 'postgres8':
+ case 'postgres7':
+ case 'postgres8':
$drivername = 'postgres';
break;
- case 'firebird15': $drivername = 'firebird'; break;
- case 'oracle': $drivername = 'oci8'; break;
- case 'access': if ($perf) $drivername = ''; break;
- case 'db2' : break;
- case 'sapdb' : break;
- default:
- $drivername = 'generic';
- break;
+ case 'firebird15':
+ $drivername = 'firebird';
+ break;
+ case 'oracle':
+ $drivername = 'oci8';
+ break;
+ case 'access':
+ if ($perf) {
+ $drivername = '';
+ }
+ break;
+ case 'db2' :
+ case 'sapdb' :
+ break;
+ default:
+ $drivername = 'generic';
+ break;
}
return $drivername;
}
- function NewPerfMonitor(&$conn)
- {
+ function NewPerfMonitor(&$conn) {
$drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true);
if (!$drivername || $drivername == 'generic') {
return false;
@@ -4439,9 +4718,10 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
return $perf;
}
- function NewDataDictionary(&$conn,$drivername=false)
- {
- if (!$drivername) $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
+ function NewDataDictionary(&$conn,$drivername=false) {
+ if (!$drivername) {
+ $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
+ }
include_once(ADODB_DIR.'/adodb-lib.inc.php');
include_once(ADODB_DIR.'/adodb-datadict.inc.php');
@@ -4458,8 +4738,9 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$dict->connection = $conn;
$dict->upperName = strtoupper($drivername);
$dict->quote = $conn->nameQuote;
- if (!empty($conn->_connectionID))
+ if (!empty($conn->_connectionID)) {
$dict->serverInfo = $conn->ServerInfo();
+ }
return $dict;
}
@@ -4469,14 +4750,16 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/*
Perform a print_r, with pre tags for better formatting.
*/
- function adodb_pr($var,$as_string=false)
- {
- if ($as_string) ob_start();
+ function adodb_pr($var,$as_string=false) {
+ if ($as_string) {
+ ob_start();
+ }
if (isset($_SERVER['HTTP_USER_AGENT'])) {
echo " <pre>\n";print_r($var);echo "</pre>\n";
- } else
+ } else {
print_r($var);
+ }
if ($as_string) {
$s = ob_get_contents();
@@ -4491,12 +4774,12 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
@param printOrArr Pass in a boolean to indicate print, or an $exception->trace array (assumes that print is true then).
@param levels Number of levels to display
*/
- function adodb_backtrace($printOrArr=true,$levels=9999,$ishtml=null)
- {
+ function adodb_backtrace($printOrArr=true,$levels=9999,$ishtml=null) {
global $ADODB_INCLUDED_LIB;
- if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
+ if (empty($ADODB_INCLUDED_LIB)) {
+ include(ADODB_DIR.'/adodb-lib.inc.php');
+ }
return _adodb_backtrace($printOrArr,$levels,0,$ishtml);
}
-
}