From: <var...@us...> - 2010-08-11 12:15:25
|
Revision: 7639 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7639&view=rev Author: vargenau Date: 2010-08-11 12:15:16 +0000 (Wed, 11 Aug 2010) Log Message: ----------- Harmonize file footer Modified Paths: -------------- trunk/lib/AccessLog.php trunk/lib/WikiDB/adodb/adodb.inc.php trunk/lib/WikiPluginCached.php trunk/lib/pear/DB/common.php trunk/lib/pear/DB/dbase.php trunk/lib/pear/DB/fbsql.php trunk/lib/pear/DB/ibase.php trunk/lib/pear/DB/ifx.php trunk/lib/pear/DB/ldap.php trunk/lib/pear/DB/msql.php trunk/lib/pear/DB/mssql.php trunk/lib/pear/DB/mysql.php trunk/lib/pear/DB/mysqli.php trunk/lib/pear/DB/oci8.php trunk/lib/pear/DB/odbc.php trunk/lib/pear/DB/pgsql.php trunk/lib/pear/DB/sqlite.php trunk/lib/pear/DB/storage.php trunk/lib/pear/DB/sybase.php trunk/lib/pear/DB.php trunk/lib/pear/PEAR.php trunk/lib/plugin/CacheTest.php trunk/lib/plugin/FacebookLike.php trunk/lib/plugin/RecentChangesCached.php trunk/lib/plugin/TexToPng.php trunk/lib/plugin/Video.php trunk/lib/plugin/text2png.php Modified: trunk/lib/AccessLog.php =================================================================== --- trunk/lib/AccessLog.php 2010-08-11 11:58:40 UTC (rev 7638) +++ trunk/lib/AccessLog.php 2010-08-11 12:15:16 UTC (rev 7639) @@ -730,10 +730,10 @@ } // Local Variables: -// mode: php -// tab-width: 8 -// c-basic-offset: 4 -// c-hanging-comment-ender-p: nil -// indent-tabs-mode: nil +// mode: php +// tab-width: 8 +// c-basic-offset: 4 +// c-hanging-comment-ender-p: nil +// indent-tabs-mode: nil // End: ?> Modified: trunk/lib/WikiDB/adodb/adodb.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/adodb.inc.php 2010-08-11 11:58:40 UTC (rev 7638) +++ trunk/lib/WikiDB/adodb/adodb.inc.php 2010-08-11 12:15:16 UTC (rev 7639) @@ -12,1958 +12,1958 @@ */ /** - \mainpage + \mainpage - @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved. + @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. You can choose which license - you prefer. + Released under both BSD license and Lesser GPL library license. You can choose which license + you prefer. - PHP's database access functions are not standardised. This creates a need for a database - class library to hide the differences between the different database API's (encapsulate - the differences) so we can easily switch databases. + PHP's database access functions are not standardised. This creates a need for a database + class library to hide the differences between the different database API's (encapsulate + the differences) so we can easily switch databases. - We currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, DB2, - Informix, PostgreSQL, FrontBase, Interbase (Firebird and Borland variants), Foxpro, Access, - ADO, SAP DB, SQLite and ODBC. We have had successful reports of connecting to Progress and - other databases via ODBC. + We currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, DB2, + Informix, PostgreSQL, FrontBase, Interbase (Firebird and Borland variants), Foxpro, Access, + ADO, SAP DB, SQLite and ODBC. We have had successful reports of connecting to Progress and + other databases via ODBC. - Latest Download at http://php.weblogs.com/adodb<br> - Manual is at http://php.weblogs.com/adodb_manual + Latest Download at http://php.weblogs.com/adodb<br> + Manual is at http://php.weblogs.com/adodb_manual */ if (!defined('_ADODB_LAYER')) { - define('_ADODB_LAYER',1); + define('_ADODB_LAYER',1); - //========================================================================== - // CONSTANT DEFINITIONS - //========================================================================== + //========================================================================== + // CONSTANT DEFINITIONS + //========================================================================== - /** - * 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__)); + /** + * 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__)); - //========================================================================== - // GLOBAL VARIABLES - //========================================================================== + //========================================================================== + // GLOBAL VARIABLES + //========================================================================== - GLOBAL - $ADODB_vers, // database version - $ADODB_COUNTRECS, // count number of records returned - slows down query - $ADODB_CACHE_DIR, // directory to cache recordsets - $ADODB_EXTENSION, // ADODB extension installed - $ADODB_COMPAT_PATCH, // 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... + GLOBAL + $ADODB_vers, // database version + $ADODB_COUNTRECS, // count number of records returned - slows down query + $ADODB_CACHE_DIR, // directory to cache recordsets + $ADODB_EXTENSION, // ADODB extension installed + $ADODB_COMPAT_PATCH, // 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... - //========================================================================== - // GLOBAL SETUP - //========================================================================== + //========================================================================== + // GLOBAL SETUP + //========================================================================== - $ADODB_EXTENSION = defined('ADODB_EXTENSION'); - if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) { + $ADODB_EXTENSION = defined('ADODB_EXTENSION'); + 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>'); + define('ADODB_BAD_RS','<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>'); - // allow [ ] @ ` " and . in table names - define('ADODB_TABLE_REGEX','([]0-9a-z_\"\`\.\@\[-]*)'); + // allow [ ] @ ` " and . in table names + define('ADODB_TABLE_REGEX','([]0-9a-z_\"\`\.\@\[-]*)'); - // prefetching used by oracle - if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10); + // prefetching used by oracle + if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10); - /* - Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names. - This currently works only with mssql, odbc, oci8po and ibase derived drivers. + /* + Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names. + This currently works only with mssql, odbc, oci8po and ibase derived drivers. - 0 = assoc lowercase field names. $rs->fields['orderid'] - 1 = assoc uppercase field names. $rs->fields['ORDERID'] - 2 = use native-case field names. $rs->fields['OrderID'] - */ + 0 = assoc lowercase field names. $rs->fields['orderid'] + 1 = assoc uppercase field names. $rs->fields['ORDERID'] + 2 = use native-case field names. $rs->fields['OrderID'] + */ - define('ADODB_FETCH_DEFAULT',0); - define('ADODB_FETCH_NUM',1); - define('ADODB_FETCH_ASSOC',2); - define('ADODB_FETCH_BOTH',3); + define('ADODB_FETCH_DEFAULT',0); + define('ADODB_FETCH_NUM',1); + 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); - if (strnatcmp(PHP_VERSION,'4.3.0')>=0) { - define('ADODB_PHPVER',0x4300); - } else if (strnatcmp(PHP_VERSION,'4.2.0')>=0) { - define('ADODB_PHPVER',0x4200); - } else if (strnatcmp(PHP_VERSION,'4.0.5')>=0) { - define('ADODB_PHPVER',0x4050); - } else { - define('ADODB_PHPVER',0x4000); - } - } + if (strnatcmp(PHP_VERSION,'4.3.0')>=0) { + define('ADODB_PHPVER',0x4300); + } else if (strnatcmp(PHP_VERSION,'4.2.0')>=0) { + define('ADODB_PHPVER',0x4200); + } else if (strnatcmp(PHP_VERSION,'4.0.5')>=0) { + define('ADODB_PHPVER',0x4050); + } else { + define('ADODB_PHPVER',0x4000); + } + } - //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 - */ - function ADODB_str_replace($src, $dest, $data) - { - if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$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); - $s = reset($src); - $d = reset($dest); - while ($s !== false) { - $data = str_replace($s,$d,$data); - $s = next($src); - $d = next($dest); - } - return $data; - } + $s = reset($src); + $d = reset($dest); + while ($s !== false) { + $data = str_replace($s,$d,$data); + $s = next($src); + $d = next($dest); + } + return $data; + } - function ADODB_Setup() - { - GLOBAL - $ADODB_vers, // database version - $ADODB_COUNTRECS, // count number of records returned - slows down query - $ADODB_CACHE_DIR, // directory to cache recordsets - $ADODB_FETCH_MODE; + function ADODB_Setup() + { + GLOBAL + $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_FETCH_DEFAULT; + $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT; - if (!isset($ADODB_CACHE_DIR)) { - $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) - die("Illegal path http:// or ftp://"); - } + if (!isset($ADODB_CACHE_DIR)) { + $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) + die("Illegal path http:// or ftp://"); + } - - // Initialize random number generator for randomizing cache flushes - srand(((double)microtime())*1000000); + + // Initialize random number generator for randomizing cache flushes + srand(((double)microtime())*1000000); - /** - * ADODB version as a string. - */ - $ADODB_vers = 'V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; + /** + * ADODB version as a string. + */ + $ADODB_vers = 'V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; - /** - * Determines whether recordset->RecordCount() is used. - * 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; - } + /** + * Determines whether recordset->RecordCount() is used. + * 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; + } - //========================================================================== - // CHANGE NOTHING BELOW UNLESS YOU ARE DESIGNING ADODB - //========================================================================== + //========================================================================== + // CHANGE NOTHING BELOW UNLESS YOU ARE DESIGNING ADODB + //========================================================================== - ADODB_Setup(); + ADODB_Setup(); - //========================================================================== - // CLASS ADOFieldObject - //========================================================================== - /** - * Helper class for FetchFields -- holds info on a column - */ - class ADOFieldObject { - var $name = ''; - var $max_length=0; - var $type=""; + //========================================================================== + // CLASS ADOFieldObject + //========================================================================== + /** + * Helper class for FetchFields -- holds info on a column + */ + class ADOFieldObject { + var $name = ''; + var $max_length=0; + var $type=""; - // additional fields by dannym... (dan...@ya...) - var $not_null = false; - // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^ - // so we can as well make not_null standard (leaving it at "false" does not harm anyways) + // additional fields by dannym... (dan...@ya...) + var $not_null = false; + // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^ + // so we can as well make not_null standard (leaving it at "false" does not harm anyways) - var $has_default = false; // this one I have done only in mysql and postgres for now ... - // others to come (dannym) - var $default_value; // default, if any, and supported. Check has_default first. - } + var $has_default = false; // this one I have done only in mysql and postgres for now ... + // others to come (dannym) + var $default_value; // default, if any, and supported. Check has_default first. + } - function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) - { - //print "Errorno ($fn errno=$errno m=$errmsg) "; - $thisConnection->_transOK = false; - if ($thisConnection->_oldRaiseFn) { - $fn = $thisConnection->_oldRaiseFn; - $fn($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) { + $fn = $thisConnection->_oldRaiseFn; + $fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection); + } + } - //========================================================================== - // CLASS ADOConnection - //========================================================================== + //========================================================================== + // CLASS ADOConnection + //========================================================================== - /** - * Connection object. For connecting to databases, and executing queries. - */ - class ADOConnection { - // - // PUBLIC VARS - // - 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 = 256000; /// maximum size of blobs or large text fields -- some databases 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 operator - var $random = 'rand()'; /// random function - var $upperCase = false; /// 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 $nameQuote = '"'; /// string to use to quote identifiers and names - var $charSet=false; /// character set to use - only for interbase - var $metaDatabasesSQL = ''; - var $metaTablesSQL = ''; - var $uniqueOrderBy = false; /// All order by columns have to be unique - var $emptyDate = ' '; - var $emptyTimeStamp = ' '; - var $lastInsID = false; - //-- - 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 $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 $sysDate = false; /// name of function that returns the current date - var $sysTimeStamp = false; /// name of function that returns the current timestamp - var $arrayClass = 'ADORecordSet_array'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets + /** + * Connection object. For connecting to databases, and executing queries. + */ + class ADOConnection { + // + // PUBLIC VARS + // + 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 = 256000; /// maximum size of blobs or large text fields -- some databases 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 operator + var $random = 'rand()'; /// random function + var $upperCase = false; /// 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 $nameQuote = '"'; /// string to use to quote identifiers and names + var $charSet=false; /// character set to use - only for interbase + var $metaDatabasesSQL = ''; + var $metaTablesSQL = ''; + var $uniqueOrderBy = false; /// All order by columns have to be unique + var $emptyDate = ' '; + var $emptyTimeStamp = ' '; + var $lastInsID = false; + //-- + 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 $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 $sysDate = false; /// name of function that returns the current date + var $sysTimeStamp = false; /// name of function that returns the current timestamp + var $arrayClass = 'ADORecordSet_array'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets - var $noNullStrings = false; /// oracle specific stuff - if true ensures that '' is converted to ' ' - var $numCacheHits = 0; - var $numCacheMisses = 0; - var $pageExecuteCountRows = true; - var $uniqueSort = false; /// indicates that all fields in order by must be unique - var $leftOuter = false; /// operator to use for left outer join in WHERE clause - var $rightOuter = false; /// operator to use for right outer join in WHERE clause - var $ansiOuter = false; /// whether ansi outer join syntax supported - var $autoRollback = false; // autoRollback on PConnect(). - var $poorAffectedRows = false; // affectedRows not working or unreliable + var $noNullStrings = false; /// oracle specific stuff - if true ensures that '' is converted to ' ' + var $numCacheHits = 0; + var $numCacheMisses = 0; + var $pageExecuteCountRows = true; + var $uniqueSort = false; /// indicates that all fields in order by must be unique + var $leftOuter = false; /// operator to use for left outer join in WHERE clause + var $rightOuter = false; /// operator to use for right outer join in WHERE clause + var $ansiOuter = false; /// whether ansi outer join syntax supported + var $autoRollback = false; // autoRollback on PConnect(). + var $poorAffectedRows = false; // affectedRows not working or unreliable - var $fnExecute = false; - var $fnCacheExecute = false; - var $blobEncodeType = false; // false=not required, 'I'=encode to integer, 'C'=encode to char - var $rsPrefix = "ADORecordSet_"; + var $fnExecute = false; + var $fnCacheExecute = false; + 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; - // - // PRIVATE VARS - // - var $_oldRaiseFn = false; - var $_transOK = null; - var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. - var $_errorMsg = false; /// A variable which was used to keep the returned last error message. The value will - /// then returned by the errorMsg() function - var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8 - var $_queryID = false; /// This variable keeps the last created result link identifier + var $fetchMode=false; + // + // PRIVATE VARS + // + var $_oldRaiseFn = false; + var $_transOK = null; + var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. + var $_errorMsg = false; /// A variable which was used to keep the returned last error message. The value will + /// then returned by the errorMsg() function + var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8 + var $_queryID = false; /// This variable keeps the last created result link identifier - var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */ - var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters. - var $_evalAll = false; - var $_affected = false; - var $_logsql = false; + var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */ + var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters. + var $_evalAll = false; + var $_affected = false; + var $_logsql = false; - /** - * Constructor - */ - function ADOConnection() - { - die('Virtual Class -- cannot instantiate'); - } + /** + * Constructor + */ + function ADOConnection() + { + die('Virtual Class -- cannot instantiate'); + } - /** - Get server version info... + /** + Get server version info... - @returns An array with 2 elements: $arr['string'] is the description string, - and $arr[version] is the version (also a string). - */ - function ServerInfo() - { - return array('description' => '', 'version' => ''); - } + @returns An array with 2 elements: $arr['string'] is the description string, + and $arr[version] is the version (also a string). + */ + function ServerInfo() + { + return array('description' => '', 'version' => ''); + } - 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. - */ - function outp($msg,$newline=true) - { - global $HTTP_SERVER_VARS,$ADODB_FLUSH,$ADODB_OUTP; + /** + * All error messages go through this bottleneck function. + * You can define your own handler by defining the function name in ADODB_OUTP. + */ + function outp($msg,$newline=true) + { + global $HTTP_SERVER_VARS,$ADODB_FLUSH,$ADODB_OUTP; - if (defined('ADODB_OUTP')) { - $fn = ADODB_OUTP; - $fn($msg,$newline); - return; - } else if (isset($ADODB_OUTP)) { - $fn = $ADODB_OUTP; - $fn($msg,$newline); - return; - } + if (defined('ADODB_OUTP')) { + $fn = ADODB_OUTP; + $fn($msg,$newline); + return; + } else if (isset($ADODB_OUTP)) { + $fn = $ADODB_OUTP; + $fn($msg,$newline); + return; + } - if ($newline) $msg .= "<br>\n"; + if ($newline) $msg .= "<br>\n"; - if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg; - else echo strip_tags($msg); - if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // dp not flush if output buffering enabled - useless - thx to Jesse Mullan + if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg; + else echo strip_tags($msg); + if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // dp not flush if output buffering enabled - useless - thx to Jesse Mullan - } + } - function Time() - { - $rs =& $this->Execute("select $this->sysTimeStamp"); - if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); + function Time() + { + $rs =& $this->Execute("select $this->sysTimeStamp"); + if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); - return false; - } + return false; + } - /** - * Connect to database - * - * @param [argHostname] Host to connect to - * @param [argUsername] Userid to login - * @param [argPassword] Associated password - * @param [argDatabaseName] database - * @param [forceNew] force new connection - * - * @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 = $argPassword; // not stored for security reasons - if ($argDatabaseName != "") $this->database = $argDatabaseName; + /** + * Connect to database + * + * @param [argHostname] Host to connect to + * @param [argUsername] Userid to login + * @param [argPassword] Associated password + * @param [argDatabaseName] database + * @param [forceNew] force new connection + * + * @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 = $argPassword; // not stored for security reasons + if ($argDatabaseName != "") $this->database = $argDatabaseName; - $this->_isPersistentConnection = false; - if ($fn = $this->raiseErrorFn) { - if ($forceNew) { - if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; - } else { - if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; - } - $err = $this->ErrorMsg(); - if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; - $fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); - } else { - if ($forceNew) { - if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; - } else { - if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; - } - } - if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); - return false; - } + $this->_isPersistentConnection = false; + if ($fn = $this->raiseErrorFn) { + if ($forceNew) { + if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; + } else { + if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; + } + $err = $this->ErrorMsg(); + if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; + $fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); + } else { + if ($forceNew) { + if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; + } else { + if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; + } + } + if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); + return false; + } - function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) - { - return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName); - } + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName); + } - /** - * Always force a new connection to database - currently only works with oracle - * - * @param [argHostname] Host to connect to - * @param [argUsername] Userid to login - * @param [argPassword] Associated password - * @param [argDatabaseName] database - * - * @return true or false - */ - function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") - { - return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName, true); - } + /** + * Always force a new connection to database - currently only works with oracle + * + * @param [argHostname] Host to connect to + * @param [argUsername] Userid to login + * @param [argPassword] Associated password + * @param [argDatabaseName] database + * + * @return true or false + */ + function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") + { + return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName, true); + } - /** - * Establish persistent connect to database - * - * @param [argHostname] Host to connect to - * @param [argUsername] Userid to login - * @param [argPassword] Associated password - * @param [argDatabaseName] database - * - * @return return true or false - */ - function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") - { - if (defined('ADODB_NEVER_PERSIST')) - return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName); + /** + * Establish persistent connect to database + * + * @param [argHostname] Host to connect to + * @param [argUsername] Userid to login + * @param [argPassword] Associated password + * @param [argDatabaseName] database + * + * @return return true or false + */ + function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") + { + 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 = $argPassword; - if ($argDatabaseName != "") $this->database = $argDatabaseName; - - $this->_isPersistentConnection = true; + if ($argHostname != "") $this->host = $argHostname; + if ($argUsername != "") $this->user = $argUsername; + if ($argPassword != "") $this->password = $argPassword; + if ($argDatabaseName != "") $this->database = $argDatabaseName; + + $this->_isPersistentConnection = true; - if ($fn = $this->raiseErrorFn) { - if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; - $err = $this->ErrorMsg(); - if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; - $fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); - } else - if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; + if ($fn = $this->raiseErrorFn) { + if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; + $err = $this->ErrorMsg(); + if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; + $fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); + } else + if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; - if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); - return false; - } + if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); + return false; + } - // 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; - return $col; // child class implement - } + // 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; + return $col; // child class implement + } - /** - * Should prepare the sql statement and return the stmt resource. - * For databases that do not support this, we return the $sql. To ensure - * compatibility with databases that do not support prepare: - * - * $stmt = $db->Prepare("insert into table (id, name) values (?,?)"); - * $db->Execute($stmt,array(1,'Jill')) or die('insert failed'); - * $db->Execute($stmt,array(2,'Joe')) or die('insert failed'); - * - * @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. - * - */ - function Prepare($sql) - { - return $sql; - } + /** + * Should prepare the sql statement and return the stmt resource. + * For databases that do not support this, we return the $sql. To ensure + * compatibility with databases that do not support prepare: + * + * $stmt = $db->Prepare("insert into table (id, name) values (?,?)"); + * $db->Execute($stmt,array(1,'Jill')) or die('insert failed'); + * $db->Execute($stmt,array(2,'Joe')) or die('insert failed'); + * + * @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. + * + */ + function Prepare($sql) + { + return $sql; + } - /** - * Some databases, eg. mssql require a different function for preparing - * stored procedures. So we cannot use Prepare(). - * - * Should prepare the stored procedure and return the stmt resource. - * For databases that do not support this, we return the $sql. To ensure - * compatibility with databases that do not support prepare: - * - * @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. - * - */ - function PrepareSP($sql,$param=true) - { - return $this->Prepare($sql,$param); - } + /** + * Some databases, eg. mssql require a different function for preparing + * stored procedures. So we cannot use Prepare(). + * + * Should prepare the stored procedure and return the stmt resource. + * For databases that do not support this, we return the $sql. To ensure + * compatibility with databases that do not support prepare: + * + * @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. + * + */ + function PrepareSP($sql,$param=true) + { + return $this->Prepare($sql,$param); + } - /** - * PEAR DB Compat - */ - function Quote($s) - { - return $this->qstr($s,false); - } + /** + * PEAR DB Compat + */ + function Quote($s) + { + return $this->qstr($s,false); + } - /** - Requested by "Karsten Dambekalns" <k.d...@fi...> - */ - function QMagic($s) - { - return $this->qstr($s,get_magic_quotes_gpc()); - } + /** + Requested by "Karsten Dambekalns" <k.d...@fi...> + */ + function QMagic($s) + { + return $this->qstr($s,get_magic_quotes_gpc()); + } - function q(&$s) - { - $s = $this->qstr($s,false); - } + function q(&$s) + { + $s = $this->qstr($s,false); + } - /** - * PEAR DB Compat - do not use internally. - */ - function ErrorNative() - { - return $this->ErrorNo(); - } + /** + * PEAR DB Compat - do not use internally. + */ + function ErrorNative() + { + return $this->ErrorNo(); + } /** - * PEAR DB Compat - do not use internally. - */ - function nextId($seq_name) - { - return $this->GenID($seq_name); - } + * PEAR DB Compat - do not use internally. + */ + 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 - * - * @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) - { - return false; - } + /** + * 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 + */ + function RowLock($table,$where) + { + return false; + } - function CommitLock($table) - { - return $this->CommitTrans(); - } + function CommitLock($table) + { + return $this->CommitTrans(); + } - function RollbackLock($table) - { - return $this->RollbackTrans(); - } + function RollbackLock($table) + { + return $this->RollbackTrans(); + } - /** - * PEAR DB Compat - do not use internally. - * - * The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical - * for easy porting :-) - * - * @param mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM - * @returns The previous fetch mode - */ - function SetFetchMode($mode) - { - $old = $this->fetchMode; - $this->fetchMode = $mode; + /** + * PEAR DB Compat - do not use internally. + * + * The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical + * for easy porting :-) + * + * @param mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM + * @returns The previous fetch mode + */ + function SetFetchMode($mode) + { + $old = $this->fetchMode; + $this->fetchMode = $mode; - if ($old === false) { - global $ADODB_FETCH_MODE; - return $ADODB_FETCH_MODE; - } - return $old; - } + if ($old === false) { + global $ADODB_FETCH_MODE; + return $ADODB_FETCH_MODE; + } + return $old; + } - /** - * PEAR DB Compat - do not use internally. - */ - function &Query($sql, $inputarr=false) - { - $rs = &$this->Execute($sql, $inputarr); - if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); - return $rs; - } + /** + * PEAR DB Compat - do not use internally. + */ + function &Query($sql, $inputarr=false) + { + $rs = &$this->Execute($sql, $inputarr); + if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); + return $rs; + } - /** - * PEAR DB Compat - do not use internally - */ - function &LimitQuery($sql, $offset, $count, $params=false) - { - $rs = &$this->SelectLimit($sql, $count, $offset, $params); - if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); - return $rs; - } + /** + * PEAR DB Compat - do not use internally + */ + function &LimitQuery($sql, $offset, $count, $params=false) + { + $rs = &$this->SelectLimit($sql, $count, $offset, $params); + if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); + return $rs; + } - /** - * PEAR DB Compat - do not use internally - */ - function Disconnect() - { - return $this->Close(); - } + /** + * PEAR DB Compat - do not use internally + */ + function Disconnect() + { + return $this->Close(); + } - /* - Returns placeholder for parameter, eg. - $DB->Param('a') + /* + Returns placeholder for parameter, eg. + $DB->Param('a') - will return ':a' for Oracle, and '?' for most other databases... + will return ':a' for Oracle, and '?' for most other databases... - For databases that require positioned params, eg $1, $2, $3 for postgresql, - pass in Param(false) before setting the first parameter. - */ - function Param($name) - { - return '?'; - } + For databases that require positioned params, eg $1, $2, $3 for postgresql, + pass in Param(false) before setting the first parameter. + */ + function Param($name) + { + return '?'; + } - /* - InParameter and OutParameter are self-documenting versions of Parameter(). - */ - function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) - { - return $this->Parameter($stmt,$var,$name,false,$maxLen,$type); - } + /* + InParameter and OutParameter are self-documenting versions of Parameter(). + */ + 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) - { - return $this->Parameter($stmt,$var,$name,true,$maxLen,$type); + /* + */ + function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) + { + return $this->Parameter($stmt,$var,$name,true,$maxLen,$type); - } + } - /* - Usage in oracle - $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); - $db->Parameter($stmt,$id,'myid'); - $db->Parameter($stmt,$group,'group',64); - $db->Execute(); + /* + Usage in oracle + $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); + $db->Parameter($stmt,$id,'myid'); + $db->Parameter($stmt,$group,'group',64); + $db->Execute(); - @param $stmt Statement returned by Prepare() or PrepareSP(). - @param $var PHP variable to bind to - @param $name Name of stored procedure variable name to bind to. - @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. - @param [$maxLen] Holds an maximum length of the variable. - @param [$type] The data type of $var. Legal values depend on driver. + @param $stmt Statement returned by Prepare() or PrepareSP(). + @param $var PHP variable to bind to + @param $name Name of stored procedure variable name to bind to. + @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. + @param [$maxLen] Holds an maximum length of the variable. + @param [$type] The data type of $var. Legal values depend on driver. - */ - function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) - { - return false; - } + */ + function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) + { + return false; + } - /** - Improved method of initiating a transaction. Used together with CompleteTrans(). - Advantages include: + /** + 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; - } + 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; + } - $this->_oldRaiseFn = $this->raiseErrorFn; - $this->raiseErrorFn = $errfn; - $this->_transOK = true; + $this->_oldRaiseFn = $this->raiseErrorFn; + $this->raiseErrorFn = $errfn; + $this->_transOK = true; - if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans"); - $this->BeginTrans(); - $this->transOff = 1; - } + if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans"); + $this->BeginTrans(); + $this->transOff = 1; + } - /** - Used together with StartTrans() to end a transaction. Monitors connection - for sql errors, and will commit or rollback as appropriate. + /** + Used together with StartTrans() to end a transaction. Monitors connection + for sql errors, and will commit or rollback as appropriate. - @autoComplete if true, monitor sql errors and commit and rollback as appropriate, - and if set to false force rollback even if no SQL error detected. - @returns true on commit, false on rollback. - */ - function CompleteTrans($autoComplete = true) - { - if ($this->transOff > 1) { - $this->transOff -= 1; - return true; - } - $this->raiseErrorFn = $this->_oldRaiseFn; + @autoComplete if true, monitor sql errors and commit and rollback as appropriate, + and if set to false force rollback even if no SQL error detected. + @returns true on commit, false on rollback. + */ + function CompleteTrans($autoComplete = true) + { + if ($this->transOff > 1) { + $this->transOff -= 1; + return true; + } + $this->raiseErrorFn = $this->_oldRaiseFn; - $this->transOff = 0; - 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"); - } else { - $this->RollbackTrans(); - if ($this->debug) ADOCOnnection::outp("Smart Rollback occurred"); - } + $this->transOff = 0; + 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"); + } else { + $this->RollbackTrans(); + if ($this->debug) ADOCOnnection::outp("Smart Rollback occurred"); + } - return $this->_transOK; - } + return $this->_transOK; + } - /* - At the end of a StartTrans/CompleteTrans block, perform a rollback. - */ - function FailTrans() - { - if ($this->debug) - if ($this->transOff == 0) { - ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans"); - } else { - ADOConnection::outp("FailTrans was called"); - adodb_backtrace(); - } - $this->_transOK = false; - } + /* + At the end of a StartTrans/CompleteTrans block, perform a rollback. + */ + function FailTrans() + { + if ($this->debug) + if ($this->transOff == 0) { + ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans"); + } else { + ADOConnection::outp("FailTrans was called"); + adodb_backtrace(); + } + $this->_transOK = false; + } - /** - Check if transaction has failed, only for Smart Transactions. - */ - function HasFailedTrans() - { - if ($this->transOff > 0) return $this->_transOK == false; - return false; - } + /** + Check if transaction has failed, only for Smart Transactions. + */ + function HasFailedTrans() + { + if ($this->transOff > 0) return $this->_transOK == false; + return false; + } - /** - * Execute SQL - * - * @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 - */ - function &Execute($sql,$inputarr=false) - { - if ($this->fnExecute) { - $fn = $this->fnExecute; - $ret =& $fn($this,$sql,$inputarr); - if (isset($ret)) return $ret; - } - if ($inputarr && is_array($inputarr)) { - $element0 = reset($inputarr); - # is_object check is because oci8 descriptors can be passed in - $array_2d = is_array($element0) && !is_object(reset($element0)); - - if (!is_array($sql) && !$this->_bindInputArray) { - $sqlarr = explode('?',$sql); - - if (!$array_2d) $inputarr = array($inputarr); - foreach($inputarr as $arr) { - $sql = ''; $i = 0; - foreach($arr as $v) { - $sql .= $sqlarr[$i]; - // from Ron Baldwin <ron...@so...> - // Only quote string types - if (gettype($v) == 'string') - $sql .= $this->qstr($v); - else if ($v === null) - $sql .= 'NULL'; - else - $sql .= $v; - $i += 1; - } - $sql .= $sqlarr[$i]; - - if ($i+1 != sizeof($sqlarr)) - ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql)); + /** + * Execute SQL + * + * @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 + */ + function &Execute($sql,$inputarr=false) + { + if ($this->fnExecute) { + $fn = $this->fnExecute; + $ret =& $fn($this,$sql,$inputarr); + if (isset($ret)) return $ret; + } + if ($inputarr && is_array($inputarr)) { + $element0 = reset($inputarr); + # is_object check is because oci8 descriptors can be passed in + $array_2d = is_array($element0) && !is_object(reset($element0)); + + if (!is_array($sql) && !$this->_bindInputArray) { + $sqlarr = explode('?',$sql); + + if (!$array_2d) $inputarr = array($inputarr); + foreach($inputarr as $arr) { + $sql = ''; $i = 0; + foreach($arr as $v) { + $sql .= $sqlarr[$i]; + // from Ron Baldwin <ron...@so...> + // Only quote string types + if (gettype($v) == 'string') + $sql .= $this->qstr($v); + else if ($v === null) + $sql .= 'NULL'; + else + $sql .= $v; + $i += 1; + } + $sql .= $sqlarr[$i]; + + if ($i+1 != sizeof($sqlarr)) + ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql)); - $ret =& $this->_Execute($sql,false); - if (!$ret) return $ret; - } - } else { - if ($array_2d) { - $stmt = $this->Prepare($sql); - foreach($inputarr as $arr) { - $ret =& $this->_Execute($stmt,$arr); - if (!$ret) return $ret; - } - } else - $ret =& $this->_Execute($sql,$inputarr); - } - } else { - $ret =& $this->_Execute($sql,false); - } + $ret =& $this->_Execute($sql,false); + if (!$ret) return $ret; + } + } else { + if ($array_2d) { + $stmt = $this->Prepare($sql); + foreach($inputarr as $arr) { + $ret =& $this->_Execute($stmt,$arr); + if (!$ret) return $ret; + } + } else + $ret =& $this->_Execute($sql,$inputarr); + } + } else { + $ret =& $this->_Execute($sql,false); + } - return $ret; - } + return $ret; + } - function& _Execute($sql,$inputarr=false) - { + function& _Execute($sql,$inputarr=false) + { - if ($this->debug) { - global $HTTP_SERVER_VARS; + if ($this->debug) { + global $HTTP_SERVER_VARS; - $ss = ''; - if ($inputarr) { - foreach($inputarr as $kk=>$vv) { - if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...'; - $ss .= "($kk=>'$vv') "; - } - $ss = "[ $ss ]"; - } - $sqlTxt = str_replace(',',', ',is_array($sql) ?$sql[0] : $sql); - - // check if running from browser or command-line - $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); - - if ($inBrowser) { - if ($this->debug === -1) - ADOConnection::outp( "<br>\n($this->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<br>\n",false); - else - ADOConnection::outp( "<hr>\n($this->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<hr>\n",false); - } else { - ADOConnection::outp("-----\n($this->databaseType): ".($sqlTxt)." \n-----\n",false); - } - $this->_queryID = $this->_query($sql,$inputarr); - /* - Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql - because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion - */ - if ($this->databaseType == 'mssql') { - // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6 - if($emsg = $this->ErrorMsg()) { - if ($err = $this->ErrorNo()) ADOConnection::outp($err.': '.$emsg); - } - } else if (!$this->_queryID) { - ADOConnection::outp($this->ErrorNo() .': '. $this->ErrorMsg()); - } - } else { - //**************************** - // non-debug version of query - //**************************** - - $this->_queryID =@$this->_query($sql,$inputarr); - } + $ss = ''; + if ($inputarr) { + foreach($inputarr as $kk=>$vv) { + if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...'; + $ss .= "($kk=>'$vv') "; + } + $ss = "[ $ss ]"; + } + $sqlTxt = str_replace(',',', ',is_array($sql) ?$sql[0] : $sql); + + // check if running from browser or command-line + $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); + + if ($inBrowser) { + if ($this->debug === -1) + ADOConnection::outp( "<br>\n($this->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<br>\n",false); + else + ADOConnection::outp( "<hr>\n($this->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<hr>\n",false); + } else { + ADOConnection::outp("-----\n($this->databaseType): ".($sqlTxt)." \n-----\n",false); + } + $this->_queryID = $this->_query($sql,$inputarr); + /* + Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql + because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion + */ + if ($this->databaseType == 'mssql') { + // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6 + if($emsg = $this->ErrorMsg()) { + if ($err = $this->ErrorNo()) ADOConnection::outp($err.': '.$emsg); + } + } else if (!$this->_queryID) { + ADOConnection::outp($this->ErrorNo() .': '. $this->ErrorMsg()); + } + } else { + //*********... [truncated message content] |