Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites
View Statistics - Next Notice - Previous NoticeDirectory filter : [ all ] / postnuke_official / html / pnadodb [ view in CVS ]
Date | Directory [filter] | File(s) [view] | Author [filter] |
07 Aug 2002 00:41:42 | postnuke_official/html/pnadodb | adodb-csvlib.inc.php,1.4,1.5 adodb-errorhandler.inc.php,1.9,1.10 adodb-errorpear.inc.php,1.9,1.10 adodb-lib.inc.php,1.8,1.9 adodb-pager.inc.php,1.2,1.3 adodb-pear.inc.php,1.9,1.10 adodb-session.php,1.9,1.10 adodb.inc.php,1.20,1.21 readme.htm,1.9,1.10 toex | Pablo Roca |
ADODB 2.30 |
Update of /home/cvsroot/postnuke_official/html/pnadodb In directory ns7.hostnuke.net:/tmp/cvs-serv21453 Modified Files: adodb-csvlib.inc.php adodb-errorhandler.inc.php adodb-errorpear.inc.php adodb-lib.inc.php adodb-pager.inc.php adodb-pear.inc.php adodb-session.php adodb.inc.php readme.htm toexport.inc.php tohtml.inc.php Log Message: ADODB 2.30 Index: adodb-csvlib.inc.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/pnadodb/adodb-csvlib.inc.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** adodb-csvlib.inc.php 10 Jul 2002 15:14:18 -0000 1.4 --- adodb-csvlib.inc.php 7 Aug 2002 00:41:40 -0000 1.5 *************** *** 34,38 **** if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete if (is_object($conn)) { ! $sql .= ','.$conn->Affected_Rows(); $sql .= ','.$conn->Insert_ID(); } else --- 34,38 ---- if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete if (is_object($conn)) { ! $sql .= ','.$conn->Affected_Rows(); $sql .= ','.$conn->Insert_ID(); } else *************** *** 189,194 **** fclose($fp); $err = "Recordset had unexpected EOF 2"; - //print "$url ";print_r($meta); - //die(); return false; } --- 189,192 ---- Index: adodb-errorhandler.inc.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/pnadodb/adodb-errorhandler.inc.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** adodb-errorhandler.inc.php 21 Jul 2002 02:24:24 -0000 1.9 --- adodb-errorhandler.inc.php 7 Aug 2002 00:41:40 -0000 1.10 *************** *** 1,5 **** <?php /** ! * @version V2.21 19 July 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, --- 1,5 ---- <?php /** ! * @version V2.30 1 Aug 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, Index: adodb-errorpear.inc.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/pnadodb/adodb-errorpear.inc.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** adodb-errorpear.inc.php 21 Jul 2002 02:24:24 -0000 1.9 --- adodb-errorpear.inc.php 7 Aug 2002 00:41:40 -0000 1.10 *************** *** 1,5 **** <?php /** ! * @version V2.21 19 July 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, --- 1,5 ---- <?php /** ! * @version V2.30 1 Aug 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, Index: adodb-lib.inc.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/pnadodb/adodb-lib.inc.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** adodb-lib.inc.php 21 Jul 2002 02:24:24 -0000 1.8 --- adodb-lib.inc.php 7 Aug 2002 00:41:40 -0000 1.9 *************** *** 109,113 **** } } else $qryRecs = $zthis->GetOne($rewritesql); ! if ($qryRecs !== false) $lastpageno = (int) ceil($qryRecs / $nrows); } --- 109,113 ---- } } else $qryRecs = $zthis->GetOne($rewritesql); ! if ($qryRecs !== false) $lastpageno = (int) ceil($qryRecs / $nrows); } *************** *** 117,122 **** $rstest = &$zthis->Execute($sql); if ($rstest) { ! //save total records ! $qryRecs = $rstest->RecordCount(); if ($qryRecs == -1) if (!$rstest->EOF) { --- 117,122 ---- $rstest = &$zthis->Execute($sql); if ($rstest) { ! //save total records ! $qryRecs = $rstest->RecordCount(); if ($qryRecs == -1) if (!$rstest->EOF) { *************** *** 126,138 **** $qryRecs = 0; ! $lastpageno = (int) ceil($qryRecs / $nrows); } if ($rstest) $rstest->Close(); } - //print "q=$qryRecs "; $zthis->_maxRecordCount = $qryRecs; ! // If page number <= 1, then we are at the first page if (!isset($page) || $page <= 1) { --- 126,137 ---- $qryRecs = 0; ! $lastpageno = (int) ceil($qryRecs / $nrows); } if ($rstest) $rstest->Close(); } $zthis->_maxRecordCount = $qryRecs; ! // If page number <= 1, then we are at the first page if (!isset($page) || $page <= 1) { *************** *** 233,238 **** // Get the full where clause excluding the word "WHERE" from // the existing query. ! preg_match("/WHERE\s(.*)/i", $rs->sql, $whereClause); ! // updateSQL will contain the full update query when all // processing has completed. --- 232,244 ---- // Get the full where clause excluding the word "WHERE" from // the existing query. ! preg_match('/\sWHERE\s(.*)/i', $rs->sql, $whereClause); ! ! // not a good hack, improvements? ! if ($whereClause) ! preg_match('/\s(LIMIT\s.*)/i', $whereClause[1], $discard); ! ! if ($discard) ! $whereClause[1] = substr($whereClause[1], 0, strlen($whereClause[1]) - strlen($discard[1])); ! // updateSQL will contain the full update query when all // processing has completed. *************** *** 268,272 **** //PostgreSQL uses a 't' or 'f' and therefore needs to be processed as a string ('C') type field. if ((substr($zthis->databaseType,0,8) == "postgres") && ($mt == "L")) $mt = "C"; ! if ($arrFields[$field->name] == 'null') $updateSQL .= $field->name . " = null, "; else --- 274,278 ---- //PostgreSQL uses a 't' or 'f' and therefore needs to be processed as a string ('C') type field. if ((substr($zthis->databaseType,0,8) == "postgres") && ($mt == "L")) $mt = "C"; ! if ($arrFields[$field->name] === 'null') $updateSQL .= $field->name . " = null, "; else *************** *** 279,283 **** case "D": $updateSQL .= $field->name . " = " . $zthis->DBDate($arrFields[$field->name]) . ", "; ! break; case "T": $updateSQL .= $field->name . " = " . $zthis->DBTimeStamp($arrFields[$field->name]) . ", "; --- 285,289 ---- case "D": $updateSQL .= $field->name . " = " . $zthis->DBDate($arrFields[$field->name]) . ", "; ! break; case "T": $updateSQL .= $field->name . " = " . $zthis->DBTimeStamp($arrFields[$field->name]) . ", "; *************** *** 288,292 **** }; }; ! }; }; --- 294,298 ---- }; }; ! }; }; *************** *** 344,348 **** // Based on the datatype of the field // Format the value properly for the database ! if ($arrFields[$field->name] == 'null') $values .= "null, "; else --- 350,354 ---- // Based on the datatype of the field // Format the value properly for the database ! if ($arrFields[$field->name] === 'null') $values .= "null, "; else *************** *** 362,367 **** break; }; ! }; ! }; // If there were any inserted fields then build the rest of the insert query. --- 368,373 ---- break; }; ! }; ! }; // If there were any inserted fields then build the rest of the insert query. Index: adodb-pager.inc.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/pnadodb/adodb-pager.inc.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** adodb-pager.inc.php 10 Jul 2002 15:14:18 -0000 1.2 --- adodb-pager.inc.php 7 Aug 2002 00:41:40 -0000 1.3 *************** *** 38,41 **** --- 38,43 ---- var $next = '<code>>></code>'; var $last = '<code>>|</code>'; + var $gridHeader = false; + var $htmlSpecialChars = true; var $page = 'Page'; var $cache = 0; #secs to cache with CachePageExecute() *************** *** 147,151 **** ob_start(); $gSQLBlockRows = $this->rows; ! rs2html($this->rs,$this->gridAttributes); $s = ob_get_contents(); ob_end_clean(); --- 149,153 ---- ob_start(); $gSQLBlockRows = $this->rows; ! rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars); $s = ob_get_contents(); ob_end_clean(); Index: adodb-pear.inc.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/pnadodb/adodb-pear.inc.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** adodb-pear.inc.php 21 Jul 2002 02:24:24 -0000 1.9 --- adodb-pear.inc.php 7 Aug 2002 00:41:40 -0000 1.10 *************** *** 1,5 **** <?php /** ! * @version V2.21 19 July 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, --- 1,5 ---- <?php /** ! * @version V2.30 1 Aug 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, *************** *** 10,15 **** * PEAR DB Emulation Layer for ADODB. * ! * The following code is modelled on PEAR DB code by Stig Bakken <ssb@fast.no> | ! * and Tomas V.V.Cox <cox@idecnet.com> */ --- 10,15 ---- * PEAR DB Emulation Layer for ADODB. * ! * The following code is modelled on PEAR DB code by Stig Bakken <ssb@fast.no> | ! * and Tomas V.V.Cox <cox@idecnet.com> */ *************** *** 44,48 **** if (!defined('DB_OK')) { ! define("DB_OK", 1); define("DB_ERROR",-1); /** --- 44,48 ---- if (!defined('DB_OK')) { ! define("DB_OK", 1); define("DB_ERROR",-1); /** *************** *** 90,136 **** class DB { ! /** ! * Create a new DB object for the specified database type ! * ! * @param $type string database type, for example "mysql" ! * ! * @return object a newly created DB object, or a DB error code on ! * error ! */ ! function &factory($type) ! { ! include_once(ADODB_DIR."/drivers/adodb-$type.inc.php"); ! $obj = &NewADOConnection($type); if (!is_object($obj)) return new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); return $obj; } ! /** ! * Create a new DB object and connect to the specified database ! * ! * @param $dsn mixed "data source name", see the DB::parseDSN ! * method for a description of the dsn format. Can also be ! * specified as an array of the format returned by DB::parseDSN. ! * ! * @param $options mixed if boolean (or scalar), tells whether ! * this connection should be persistent (for backends that support ! * this). This parameter can also be an array of options, see ! * DB_common::setOption for more information on connection ! * options. ! * ! * @return object a newly created DB connection object, or a DB ! * error object on error ! * ! * @see DB::parseDSN ! * @see DB::isError ! */ ! function &connect($dsn, $options = false) ! { ! if (is_array($dsn)) { ! $dsninfo = $dsn; ! } else { ! $dsninfo = DB::parseDSN($dsn); ! } switch ($dsninfo["phptype"]) { case 'pgsql': $type = 'postgres7'; break; --- 90,136 ---- class DB { ! /** ! * Create a new DB object for the specified database type ! * ! * @param $type string database type, for example "mysql" ! * ! * @return object a newly created DB object, or a DB error code on ! * error ! */ ! function &factory($type) ! { ! include_once(ADODB_DIR."/drivers/adodb-$type.inc.php"); ! $obj = &NewADOConnection($type); if (!is_object($obj)) return new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); return $obj; } ! /** ! * Create a new DB object and connect to the specified database ! * ! * @param $dsn mixed "data source name", see the DB::parseDSN ! * method for a description of the dsn format. Can also be ! * specified as an array of the format returned by DB::parseDSN. ! * ! * @param $options mixed if boolean (or scalar), tells whether ! * this connection should be persistent (for backends that support ! * this). This parameter can also be an array of options, see ! * DB_common::setOption for more information on connection ! * options. ! * ! * @return object a newly created DB connection object, or a DB ! * error object on error ! * ! * @see DB::parseDSN ! * @see DB::isError ! */ ! function &connect($dsn, $options = false) ! { ! if (is_array($dsn)) { ! $dsninfo = $dsn; ! } else { ! $dsninfo = DB::parseDSN($dsn); ! } switch ($dsninfo["phptype"]) { case 'pgsql': $type = 'postgres7'; break; *************** *** 139,158 **** } ! if (is_array($options) && isset($options["debug"]) && ! $options["debug"] >= 2) { ! // expose php errors with sufficient debug level ! @include_once("adodb-$type.inc.php"); ! } else { ! @include_once("adodb-$type.inc.php"); ! } ! @$obj =&NewADOConnection($type); if (!is_object($obj)) return new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); ! if (is_array($options)) { ! $persist = !empty($options['persistent']); ! } else { ! $persist = true; ! } if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); --- 139,158 ---- } ! if (is_array($options) && isset($options["debug"]) && ! $options["debug"] >= 2) { ! // expose php errors with sufficient debug level ! @include_once("adodb-$type.inc.php"); ! } else { ! @include_once("adodb-$type.inc.php"); ! } ! @$obj =&NewADOConnection($type); if (!is_object($obj)) return new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); ! if (is_array($options)) { ! $persist = !empty($options['persistent']); ! } else { ! $persist = true; ! } if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); *************** *** 160,341 **** if (!$ok) return ADODB_PEAR_Error(); ! return $obj; ! } ! /** ! * Return the DB API version ! * ! * @return int the DB API version number ! */ ! function apiVersion() ! { ! return 2; ! } ! /** ! * Tell whether a result code from a DB method is an error ! * ! * @param $value int result code ! * ! * @return bool whether $value is an error ! */ ! function isError($value) ! { ! return (is_object($value) && ! (get_class($value) == 'db_error' || ! is_subclass_of($value, 'db_error'))); ! } ! /** ! * Tell whether a result code from a DB method is a warning. ! * Warnings differ from errors in that they are generated by DB, ! * and are not fatal. ! * ! * @param $value mixed result value ! * ! * @return bool whether $value is a warning ! */ ! function isWarning($value) ! { ! return is_object($value) && ! (get_class( $value ) == "db_warning" || ! is_subclass_of($value, "db_warning")); ! } ! /** ! * Parse a data source name ! * ! * @param $dsn string Data Source Name to be parsed ! * ! * @return array an associative array with the following keys: ! * ! * phptype: Database backend used in PHP (mysql, odbc etc.) ! * dbsyntax: Database used with regards to SQL syntax etc. ! * protocol: Communication protocol to use (tcp, unix etc.) ! * hostspec: Host specification (hostname[:port]) ! * database: Database to use on the DBMS server ! * username: User name for login ! * password: Password for login ! * ! * The format of the supplied DSN is in its fullest form: ! * ! * phptype(dbsyntax)://username:password@protocol+hostspec/database ! * ! * Most variations are allowed: ! * ! * phptype://username:password@protocol+hostspec:110//usr/db_file.db ! * phptype://username:password@hostspec/database_name ! * phptype://username:password@hostspec ! * phptype://username@hostspec ! * phptype://hostspec/database ! * phptype://hostspec ! * phptype(dbsyntax) ! * phptype ! * ! * @author Tomas V.V.Cox <cox@idecnet.com> ! */ ! function parseDSN($dsn) ! { ! if (is_array($dsn)) { ! return $dsn; ! } ! $parsed = array( ! 'phptype' => false, ! 'dbsyntax' => false, ! 'protocol' => false, ! 'hostspec' => false, ! 'database' => false, ! 'username' => false, ! 'password' => false ! ); ! // Find phptype and dbsyntax ! if (($pos = strpos($dsn, '://')) !== false) { ! $str = substr($dsn, 0, $pos); ! $dsn = substr($dsn, $pos + 3); ! } else { ! $str = $dsn; ! $dsn = NULL; ! } ! // Get phptype and dbsyntax ! // $str => phptype(dbsyntax) ! if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { ! $parsed['phptype'] = $arr[1]; ! $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; ! } else { ! $parsed['phptype'] = $str; ! $parsed['dbsyntax'] = $str; ! } ! if (empty($dsn)) { ! return $parsed; ! } ! // Get (if found): username and password ! // $dsn => username:password@protocol+hostspec/database ! if (($at = strpos($dsn,'@')) !== false) { ! $str = substr($dsn, 0, $at); ! $dsn = substr($dsn, $at + 1); ! if (($pos = strpos($str, ':')) !== false) { ! $parsed['username'] = urldecode(substr($str, 0, $pos)); ! $parsed['password'] = urldecode(substr($str, $pos + 1)); ! } else { ! $parsed['username'] = urldecode($str); ! } ! } ! // Find protocol and hostspec ! // $dsn => protocol+hostspec/database ! if (($pos=strpos($dsn, '/')) !== false) { ! $str = substr($dsn, 0, $pos); ! $dsn = substr($dsn, $pos + 1); ! } else { ! $str = $dsn; ! $dsn = NULL; ! } ! // Get protocol + hostspec ! // $str => protocol+hostspec ! if (($pos=strpos($str, '+')) !== false) { ! $parsed['protocol'] = substr($str, 0, $pos); ! $parsed['hostspec'] = urldecode(substr($str, $pos + 1)); ! } else { ! $parsed['hostspec'] = urldecode($str); ! } ! // Get dabase if any ! // $dsn => database ! if (!empty($dsn)) { ! $parsed['database'] = $dsn; ! } ! return $parsed; ! } ! /** ! * Load a PHP database extension if it is not loaded already. ! * ! * @access public ! * ! * @param $name the base name of the extension (without the .so or ! * .dll suffix) ! * ! * @return bool true if the extension was already or successfully ! * loaded, false if it could not be loaded ! */ ! function assertExtension($name) ! { ! if (!extension_loaded($name)) { ! $dlext = (substr(PHP_OS, 0, 3) == 'WIN') ? '.dll' : '.so'; ! @dl($name . $dlext); ! } ! if (!extension_loaded($name)) { ! return false; ! } ! return true; ! } } --- 160,341 ---- if (!$ok) return ADODB_PEAR_Error(); ! return $obj; ! } ! /** ! * Return the DB API version ! * ! * @return int the DB API version number ! */ ! function apiVersion() ! { ! return 2; ! } ! /** ! * Tell whether a result code from a DB method is an error ! * ! * @param $value int result code ! * ! * @return bool whether $value is an error ! */ ! function isError($value) ! { ! return (is_object($value) && ! (get_class($value) == 'db_error' || ! is_subclass_of($value, 'db_error'))); ! } ! /** ! * Tell whether a result code from a DB method is a warning. ! * Warnings differ from errors in that they are generated by DB, ! * and are not fatal. ! * ! * @param $value mixed result value ! * ! * @return bool whether $value is a warning ! */ ! function isWarning($value) ! { ! return is_object($value) && ! (get_class( $value ) == "db_warning" || ! is_subclass_of($value, "db_warning")); ! } ! /** ! * Parse a data source name ! * ! * @param $dsn string Data Source Name to be parsed ! * ! * @return array an associative array with the following keys: ! * ! * phptype: Database backend used in PHP (mysql, odbc etc.) ! * dbsyntax: Database used with regards to SQL syntax etc. ! * protocol: Communication protocol to use (tcp, unix etc.) ! * hostspec: Host specification (hostname[:port]) ! * database: Database to use on the DBMS server ! * username: User name for login ! * password: Password for login ! * ! * The format of the supplied DSN is in its fullest form: ! * ! * phptype(dbsyntax)://username:password@protocol+hostspec/database ! * ! * Most variations are allowed: ! * ! * phptype://username:password@protocol+hostspec:110//usr/db_file.db ! * phptype://username:password@hostspec/database_name ! * phptype://username:password@hostspec ! * phptype://username@hostspec ! * phptype://hostspec/database ! * phptype://hostspec ! * phptype(dbsyntax) ! * phptype ! * ! * @author Tomas V.V.Cox <cox@idecnet.com> ! */ ! function parseDSN($dsn) ! { ! if (is_array($dsn)) { ! return $dsn; ! } ! $parsed = array( ! 'phptype' => false, ! 'dbsyntax' => false, ! 'protocol' => false, ! 'hostspec' => false, ! 'database' => false, ! 'username' => false, ! 'password' => false ! ); ! // Find phptype and dbsyntax ! if (($pos = strpos($dsn, '://')) !== false) { ! $str = substr($dsn, 0, $pos); ! $dsn = substr($dsn, $pos + 3); ! } else { ! $str = $dsn; ! $dsn = NULL; ! } ! // Get phptype and dbsyntax ! // $str => phptype(dbsyntax) ! if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { ! $parsed['phptype'] = $arr[1]; ! $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; ! } else { ! $parsed['phptype'] = $str; ! $parsed['dbsyntax'] = $str; ! } ! if (empty($dsn)) { ! return $parsed; ! } ! // Get (if found): username and password ! // $dsn => username:password@protocol+hostspec/database ! if (($at = strpos($dsn,'@')) !== false) { ! $str = substr($dsn, 0, $at); ! $dsn = substr($dsn, $at + 1); ! if (($pos = strpos($str, ':')) !== false) { ! $parsed['username'] = urldecode(substr($str, 0, $pos)); ! $parsed['password'] = urldecode(substr($str, $pos + 1)); ! } else { ! $parsed['username'] = urldecode($str); ! } ! } ! // Find protocol and hostspec ! // $dsn => protocol+hostspec/database ! if (($pos=strpos($dsn, '/')) !== false) { ! $str = substr($dsn, 0, $pos); ! $dsn = substr($dsn, $pos + 1); ! } else { ! $str = $dsn; ! $dsn = NULL; ! } ! // Get protocol + hostspec ! // $str => protocol+hostspec ! if (($pos=strpos($str, '+')) !== false) { ! $parsed['protocol'] = substr($str, 0, $pos); ! $parsed['hostspec'] = urldecode(substr($str, $pos + 1)); ! } else { ! $parsed['hostspec'] = urldecode($str); ! } ! // Get dabase if any ! // $dsn => database ! if (!empty($dsn)) { ! $parsed['database'] = $dsn; ! } ! return $parsed; ! } ! /** ! * Load a PHP database extension if it is not loaded already. ! * ! * @access public ! * ! * @param $name the base name of the extension (without the .so or ! * .dll suffix) ! * ! * @return bool true if the extension was already or successfully ! * loaded, false if it could not be loaded ! */ ! function assertExtension($name) ! { ! if (!extension_loaded($name)) { ! $dlext = (substr(PHP_OS, 0, 3) == 'WIN') ? '.dll' : '.so'; ! @dl($name . $dlext); ! } ! if (!extension_loaded($name)) { ! return false; ! } ! return true; ! } } Index: adodb-session.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/pnadodb/adodb-session.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** adodb-session.php 21 Jul 2002 02:24:24 -0000 1.9 --- adodb-session.php 7 Aug 2002 00:41:40 -0000 1.10 *************** *** 30,37 **** create table sessions ( ! SESSKEY char(32) not null, ! EXPIRY int(11) unsigned not null, ! DATA text not null, ! primary key (sesskey) ); --- 30,37 ---- create table sessions ( ! SESSKEY char(32) not null, ! EXPIRY int(11) unsigned not null, ! DATA text not null, ! primary key (sesskey) ); *************** *** 46,50 **** 3. Recommended is PHP 4.0.6 or later. There are documented ! session bugs in earlier versions of PHP. */ --- 46,50 ---- 3. Recommended is PHP 4.0.6 or later. There are documented ! session bugs in earlier versions of PHP. */ *************** *** 106,110 **** { GLOBAL $ADODB_SESS_CONN; - //if( $persist) print "PERSIST "; if (isset($ADODB_SESS_CONN)) return true; --- 106,109 ---- *************** *** 120,124 **** if (!empty($ADODB_SESS_DEBUG)) { $ADODB_SESS_CONN->debug = true; ! print " conn=$ADODB_SESSION_CONNECT user=$ADODB_SESSION_USER pwd=$ADODB_SESSION_PWD db=$ADODB_SESSION_DB "; } if ($persist) $ok = $ADODB_SESS_CONN->PConnect($ADODB_SESSION_CONNECT, --- 119,123 ---- if (!empty($ADODB_SESS_DEBUG)) { $ADODB_SESS_CONN->debug = true; ! ADOConnection::outp( " conn=$ADODB_SESSION_CONNECT user=$ADODB_SESSION_USER pwd=$ADODB_SESSION_PWD db=$ADODB_SESSION_DB "); } if ($persist) $ok = $ADODB_SESS_CONN->PConnect($ADODB_SESSION_CONNECT, *************** *** 127,131 **** $ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB); ! if (!$ok) print "<p>Session: connection failed</p>"; } --- 126,130 ---- $ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB); ! if (!$ok) ADOConnection::outp( "<p>Session: connection failed</p>",false); } *************** *** 194,198 **** $rs = $ADODB_SESS_CONN->Execute($qry); if ($rs) $rs->Close(); ! else print '<p>Session Update: '.$ADODB_SESS_CONN->ErrorMsg().'</p>'; if ($ADODB_SESS_INSERT || $rs === false) { --- 193,197 ---- $rs = $ADODB_SESS_CONN->Execute($qry); if ($rs) $rs->Close(); ! else ADOConnection::outp( '<p>Session Update: '.$ADODB_SESS_CONN->ErrorMsg().'</p>',false); if ($ADODB_SESS_INSERT || $rs === false) { *************** *** 200,204 **** $rs = $ADODB_SESS_CONN->Execute($qry); if ($rs) $rs->Close(); ! else print '<p>Session Insert: '.$ADODB_SESS_CONN->ErrorMsg().'</p>'; } // bug in access driver (could be odbc?) means that info is not commited --- 199,203 ---- $rs = $ADODB_SESS_CONN->Execute($qry); if ($rs) $rs->Close(); ! else ADOConnection::outp('<p>Session Insert: '.$ADODB_SESS_CONN->ErrorMsg().'</p>',false); } // bug in access driver (could be odbc?) means that info is not commited *************** *** 262,266 **** session_register('AVAR'); $HTTP_SESSION_VARS['AVAR'] += 1; ! print "<p>\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}</p>"; } --- 261,265 ---- session_register('AVAR'); $HTTP_SESSION_VARS['AVAR'] += 1; ! ADOConnection::outp( "<p>\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}</p>",false); } Index: adodb.inc.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/pnadodb/adodb.inc.php,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** adodb.inc.php 21 Jul 2002 02:24:24 -0000 1.20 --- adodb.inc.php 7 Aug 2002 00:41:40 -0000 1.21 *************** *** 2,6 **** /** ! * @version V2.21 19 July 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, --- 2,6 ---- /** ! * @version V2.30 1 Aug 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * Released under both BSD license and Lesser GPL library license. * Whenever there is any discrepancy between the two licenses, *************** *** 199,202 **** --- 199,219 ---- } + // 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; + + if (defined('ADODB_OUTP')) { + $fn = ADODB_OUTP; + $fn($msg,$newline); + return; + } + + if ($newline) $msg .= "<br>\n"; + + if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg; + else echo strip_tags($msg); + } /** *************** *** 226,235 **** if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; ! if ($this->debug) print $this->host.': '.$this->ErrorMsg()."<br />\n"; return false; } - /** * Establish persistent connect to database --- 243,251 ---- if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; ! if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); return false; } /** * Establish persistent connect to database *************** *** 259,263 **** if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; ! if ($this->debug) print $this->host.': '.$this->ErrorMsg()."<br />\n"; return false; --- 275,279 ---- if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; ! if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); return false; *************** *** 459,463 **** $sql .= $sqlarr[$i]; if ($i+1 != sizeof($sqlarr)) ! print "Input Array does not match ?: ".htmlspecialchars($sql); $inputarr = false; } --- 475,479 ---- $sql .= $sqlarr[$i]; if ($i+1 != sizeof($sqlarr)) ! ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql)); $inputarr = false; } *************** *** 482,488 **** if ($inBrowser) ! print "<hr />\n($this->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<hr />\n"; else ! print "=----\n($this->databaseType): ".($sqlTxt)." \n-----\n"; flush(); --- 498,504 ---- if ($inBrowser) ! 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); flush(); *************** *** 499,503 **** $err = $this->ErrorNo(); if ($err) { ! print $err.': '.$emsg.(($inBrowser) ? "<br />\n" : "\n"); flush(); } --- 515,519 ---- $err = $this->ErrorNo(); if ($err) { ! ADOConnection::outp($err.': '.$emsg); flush(); } *************** *** 505,509 **** } else if (!$this->_queryID) { ! print $this->ErrorNo().': '.$this->ErrorMsg() .(($inBrowser) ? "<br />\n" : "\n"); flush(); } --- 521,525 ---- } else if (!$this->_queryID) { ! ADOConnection::outp( $this->ErrorNo().': '.$this->ErrorMsg() ); flush(); } *************** *** 596,600 **** { if ($this->hasInsertID) return $this->_insertid(); ! if ($this->debug) print '<p>Insert_ID error</p>'; return false; } --- 612,616 ---- { if ($this->hasInsertID) return $this->_insertid(); ! if ($this->debug) ADOConnection::outp( '<p>Insert_ID error</p>'); return false; } *************** *** 627,631 **** } ! if ($this->debug) print '<p>Affected_Rows error</p>'; return false; } --- 643,647 ---- } ! if ($this->debug) ADOConnection::outp( '<p>Affected_Rows error</p>',false); return false; } *************** *** 694,698 **** // suggested by Reinhard Balling. Access requires top after distinct // Informix requires first before distinct - F Riosa ! $isaccess = (strpos($this->databaseType,'access') !== false); if ($offset <= 0) { --- 710,717 ---- // 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) { *************** *** 702,709 **** '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nrows.' ',$sql); - // access includes ties in result - if (strpos($this->databaseType,'access') !== false) if ($secs2cache>0) return $this->CacheExecute($secs2cache, $sql,$inputarr,$arg3); else return $this->Execute($sql,$inputarr,$arg3); } else { $sql = preg_replace( --- 721,729 ---- '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nrows.' ',$sql); if ($secs2cache>0) return $this->CacheExecute($secs2cache, $sql,$inputarr,$arg3); else return $this->Execute($sql,$inputarr,$arg3); + } else if ($ismssql){ + $sql = preg_replace( + '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nrows.' ',$sql); } else { $sql = preg_replace( *************** *** 712,716 **** } else { $nn = $nrows + $offset; ! if ($isaccess) { $sql = preg_replace( '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql); --- 732,736 ---- } else { $nn = $nrows + $offset; ! if ($isaccess || $ismssql) { $sql = preg_replace( '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql); *************** *** 1011,1015 **** return $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$inputarr,$this->cacheSecs); } ! if ($sql === false) echo "Warning: \$sql missing from CacheSelectLimit()<br />\n"; return $this->SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache); } --- 1031,1035 ---- return $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$inputarr,$this->cacheSecs); } ! if ($sql === false) ADOConnection::outp( "Warning: \$sql missing from CacheSelectLimit()"); return $this->SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache); } *************** *** 1027,1031 **** } if ($this->debug) { ! echo "CacheFlush: $cmd<br><pre>\n", system($cmd),"</pre>"; } else { exec($cmd); --- 1047,1051 ---- } if ($this->debug) { ! ADOConnection::outp( "CacheFlush: $cmd<br><pre>\n", system($cmd),"</pre>"); } else { exec($cmd); *************** *** 1047,1051 **** if ($createdir) if(!file_exists($dir) && !mkdir($dir,0771)) ! if ($this->debug) print "Unable to mkdir $dir for $sql<br>\n"; return $dir.'/adodb_'.$m.'.cache'; } --- 1067,1071 ---- if ($createdir) if(!file_exists($dir) && !mkdir($dir,0771)) ! if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql"); return $dir.'/adodb_'.$m.'.cache'; } *************** *** 1089,1093 **** // no cached rs found if ($this->debug) { ! print " $md5file cache failure: $err<br>\n"; } $rs = &$this->Execute($sql,$inputarr,$arg3); --- 1109,1113 ---- // no cached rs found if ($this->debug) { ! ADOConnection::outp( " $md5file cache failure: $err (see sql below)"); } $rs = &$this->Execute($sql,$inputarr,$arg3); *************** *** 1101,1105 **** $fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql); } ! if ($this->debug) print " Cache write error<br>\n"; } if ($rs->EOF && !$eof) { --- 1121,1125 ---- $fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql); } ! if ($this->debug) ADOConnection::outp( " Cache write error"); } if ($rs->EOF && !$eof) { *************** *** 1122,1126 **** if ($inBrowser) $s = '<i>'.htmlspecialchars($s).'</i>'; ! print " $md5file reloaded, ttl=$ttl [ $s ] <br>\n"; } } --- 1142,1146 ---- if ($inBrowser) $s = '<i>'.htmlspecialchars($s).'</i>'; ! ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]"); } } *************** *** 2617,2621 **** $dbtype); } else ! print "<p>ADONewConnection: Unable to load database driver '$db'</p>"; return false; --- 2637,2641 ---- $dbtype); } else ! ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false); return false; *************** *** 2663,2667 **** } if (!$ok) { ! if ($debug) print " Rename $tmpname ".($ok? 'ok' : 'failed')." <br />\n"; } return $ok; --- 2683,2687 ---- } if (!$ok) { ! if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); } return $ok; *************** *** 2674,2678 **** }else { fclose($fd); ! if ($debug)print " Failed acquiring lock for $filename<br>\n"; $ok = false; } --- 2694,2698 ---- }else { fclose($fd); ! if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n"); $ok = false; } Index: readme.htm =================================================================== RCS file: /home/cvsroot/postnuke_official/html/pnadodb/readme.htm,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** readme.htm 21 Jul 2002 02:24:24 -0000 1.9 --- readme.htm 7 Aug 2002 00:41:40 -0000 1.10 *************** *** 13,17 **** <h2>ADOdb Library for PHP</h2> ! <p>V2.20 9 July 2002 (c) 2000-2002 John Lim (<a href="mailto:jlim@natsoft.com.my">jlim@natsoft.com.my</a>)</p> <p>This software is dual licensed using BSD-Style and LGPL. Where there is any discrepancy, the BSD-Style license will take precedence. --- 13,17 ---- <h2>ADOdb Library for PHP</h2> ! <p>V2.30 1 Aug 2002 (c) 2000-2002 John Lim (<a href="mailto:jlim@natsoft.com.my">jlim@natsoft.com.my</a>)</p> <p>This software is dual licensed using BSD-Style and LGPL. Where there is any discrepancy, the BSD-Style license will take precedence. *************** *** 37,41 **** <b> <a href="#errorhandling">Using Custom Error Handlers and PEAR_Error</a><br> <a href="#DSN">Data Source Names</a><br> ! <a href="#caching">Caching</a></b></p> <p><a href="#ref"><b>REFERENCE</b></a><br> <a href="#ADOConnection"><b><br> --- 37,42 ---- <b> <a href="#errorhandling">Using Custom Error Handlers and PEAR_Error</a><br> <a href="#DSN">Data Source Names</a><br> ! <a href="#caching">Caching</a><br> ! <a href="#pivot">Pivot Tables</a></b><p></p> <p><a href="#ref"><b>REFERENCE</b></a><br> <a href="#ADOConnection"><b><br> *************** *** 48,52 **** <a href="#getone">GetOne</a> <a href="#cachegetone"><i>CacheGetOne</i></a> <a href="#getrow">GetRow</a> <a href="#cachegetrow"><i>CacheGetRow</i></a> ! <a href="#getall">GetAll</a> <a href="#cachegetall"><i>CacheGetAll</i></a> <a href="#replace">Replace</a> <br> Generates SQL: <a href="#getupdatesql">GetUpdateSQL</a> <a href="#getinsertsql">GetInsertSQL</a></font><font size="2"><br> --- 49,54 ---- <a href="#getone">GetOne</a> <a href="#cachegetone"><i>CacheGetOne</i></a> <a href="#getrow">GetRow</a> <a href="#cachegetrow"><i>CacheGetRow</i></a> ! <a href="#getall">GetAll</a> <a href="#cachegetall"><i>CacheGetAll</i></a> ! <a href="#getcol">GetCol</a> <a href="#cachegetcol"><i>CacheGetCol</i></a> <a href="#replace">Replace</a> <br> Generates SQL: <a href="#getupdatesql">GetUpdateSQL</a> <a href="#getinsertsql">GetInsertSQL</a></font><font size="2"><br> *************** *** 114,126 **** <ul> <li><b>Easy for Windows programmers</b> to adapt to because many of the conventions ! are similar to Microsoft's ADO.</li> <li>Unlike other PHP database classes which focus only on select statements, ! <b>we provide support code to handle inserts and updates which can be adapted ! to multiple databases quickly.</b> Methods are provided for date handling, ! string concatenation and string quoting characters for differing databases.</li> <li>A<b> metatype system </b>is built in so that we can figure out that types ! such as CHAR, TEXT and STRING are equivalent in different databases.</li> <li><b>Easy to port</b> because all the database dependant code are stored in ! stub functions. You do not need to port the core logic of the classes.</li> <li><b>PHP4 session support</b>. See adodb-session.php.</li> </ul> --- 116,128 ---- <ul> <li><b>Easy for Windows programmers</b> to adapt to because many of the conventions ! are similar to Microsoft's ADO.</li> <li>Unlike other PHP database classes which focus only on select statements, ! <b>we provide support code to handle inserts and updates which can be adapted ! to multiple databases quickly.</b> Methods are provided for date handling, ! string concatenation and string quoting characters for differing databases.</li> <li>A<b> metatype system </b>is built in so that we can figure out that types ! such as CHAR, TEXT and STRING are equivalent in different databases.</li> <li><b>Easy to port</b> because all the database dependant code are stored in ! stub functions. You do not need to port the core logic of the classes.</li> <li><b>PHP4 session support</b>. See adodb-session.php.</li> </ul> *************** *** 313,317 **** </td> </tr> ! <tr valign="top"> <td height="73"><b><font size="2">mssqlpo</font></b></td> <td height="73"><font size="2">A</font></td> --- 315,319 ---- </td> </tr> ! <tr valign="top"> <td height="73"><b><font size="2">mssqlpo</font></b></td> <td height="73"><font size="2">A</font></td> *************** *** 512,517 **** <pre> <? ! <font face="Courier New, Courier, mono"><b>include</b>('adodb.inc.php'); # load code common to ADOdb ! $<font color="#660000">conn</font> = &ADONewConnection('access'); # create a connection $<font color="#660000">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind DSN $<font color="#660000">recordSet</font> = &$<font color="#660000">conn</font>->Execute('select * from products'); --- 514,519 ---- <pre> <? ! <font face="Courier New, Courier, mono"><b>include</b>('adodb.inc.php'); # load code common to ADOdb ! $<font color="#660000">conn</font> = &ADONewConnection('access'); # create a connection $<font color="#660000">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind DSN $<font color="#660000">recordSet</font> = &$<font color="#660000">conn</font>->Execute('select * from products'); *************** *** 556,561 **** <pre> <? ! <font face="Courier New, Courier, mono"><b>include</b>('adodb.inc.php'); # load code common to ADOdb ! $<font color="#660000">conn</font> = &ADONewConnection('access'); # create a connection $<font color="#660000">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind dsn $<font color="#660000">recordSet</font> = &$<font color="#660000">conn</font>->Execute('select CustomerID,OrderDate from Orders'); --- 558,563 ---- <pre> <? ! <font face="Courier New, Courier, mono"><b>include</b>('adodb.inc.php'); # load code common to ADOdb ! $<font color="#660000">conn</font> = &ADONewConnection('access'); # create a connection $<font color="#660000">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind dsn $<font color="#660000">recordSet</font> = &$<font color="#660000">conn</font>->Execute('select CustomerID,OrderDate from Orders'); *************** *** 615,620 **** <pre> <? ! <b>include</b>('adodb.inc.php'); # load code common to ADOdb ! $<font color="#660000">conn</font> = &ADONewConnection('access'); # create a connection $<font color="#660000">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind dsn --- 617,622 ---- <pre> <? ! <b>include</b>('adodb.inc.php'); # load code common to ADOdb ! $<font color="#660000">conn</font> = &ADONewConnection('access'); # create a connection $<font color="#660000">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind dsn *************** *** 643,648 **** <h3> Example 4: Debugging<a name="ex4"></a></h3> <pre><? ! <b>include</b>('adodb.inc.php'); # load code common to ADOdb ! $<font color="#663300">conn</font> = &ADONewConnection('access'); # create a connection $<font color="#663300">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind dsn <font color="#000000">$<font color="#663300">shipto</font> = <b>$conn->qstr</b>("John's Old Shoppe"); --- 645,650 ---- <h3> Example 4: Debugging<a name="ex4"></a></h3> <pre><? ! <b>include</b>('adodb.inc.php'); # load code common to ADOdb ! $<font color="#663300">conn</font> = &ADONewConnection('access'); # create a connection $<font color="#663300">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind dsn <font color="#000000">$<font color="#663300">shipto</font> = <b>$conn->qstr</b>("John's Old Shoppe"); *************** *** 681,685 **** <h3>Example 6: Connecting to 2 Databases At Once<a name="ex6"></a></h3> <pre><? ! <b>include</b>('adodb.inc.php'); # load code common to ADOdb $<font color="#663300">conn1</font> = &ADONewConnection('mysql'); # create a mysql connection $<font color="#663300">conn2</font> = &ADONewConnection('oracle'); # create a oracle connection --- 683,687 ---- <h3>Example 6: Connecting to 2 Databases At Once<a name="ex6"></a></h3> <pre><? ! <b>include</b>('adodb.inc.php'); # load code common to ADOdb $<font color="#663300">conn1</font> = &ADONewConnection('mysql'); # create a mysql connection $<font color="#663300">conn2</font> = &ADONewConnection('oracle'); # create a oracle connection *************** *** 832,836 **** databases): <pre>$sql = 'select id as "ID", firstname as "First Name", ! lastname as "Last Name", created as "Date Created" <br> from adoxyz';</pre> <p>The above code can be found in the <i>adodb/tests/testpaging.php</i> example included with this release, and the class ADODB_Pager in <i>adodb/adodb-pager.inc.php</i>. --- 834,838 ---- databases): <pre>$sql = 'select id as "ID", firstname as "First Name", ! lastname as "Last Name", created as "Date Created" <br> from adoxyz';</pre> <p>The above code can be found in the <i>adodb/tests/testpaging.php</i> example included with this release, and the class ADODB_Pager in <i>adodb/adodb-pager.inc.php</i>. *************** *** 848,852 **** print "<pre>";<br>print <b>rs2csv</b>($rs); # return a string, CSV format<p>print '<hr>'; <br>$rs->MoveFirst(); # note, some databases do not support MoveFirst<br>print <b>rs2tab</b>($rs,<i>false</i>); # return a string, tab-delimited ! # false == suppress field names in first line</p>print '<hr>';<br>$rs->MoveFirst();<br><b>rs2tabout</b>($rs); # send to stdout directly (there is also an rs2csvout function) print "</pre>"; --- 850,854 ---- print "<pre>";<br>print <b>rs2csv</b>($rs); # return a string, CSV format<p>print '<hr>'; <br>$rs->MoveFirst(); # note, some databases do not support MoveFirst<br>print <b>rs2tab</b>($rs,<i>false</i>); # return a string, tab-delimited ! # false == suppress field names in first line</p>print '<hr>';<br>$rs->MoveFirst();<br><b>rs2tabout</b>($rs); # send to stdout directly (there is also an rs2csvout function) print "</pre>"; *************** *** 1001,1008 **** </pre> <font color="#000000"> ! <hr> <h1>Class Reference<a name="Ref"></a></h1> <p>Function parameters with [ ] around them are optional.</p> ! </font> <h2>Global Variables</h2> <h3>$ADODB_COUNTRECS</h3> --- 1003,1154 ---- </pre> <font color="#000000"> ! <h2><a name="pivot"></a>Pivot Tables</h2> ! </font> ! <p><font color="#000000">Since ADOdb 2.3, we support the generation of SQL to ! create pivot tables, also known as cross-tabulations. For further explanation ! read this DevShed <a href=http://www.devshed.com/Server_Side/MySQL/MySQLWiz/>Cross-Tabulation ! tutorial</a>. We assume that your database supports the SQL case-when expression.</font></p> ! <font color="#000000"> ! <p>In this example, we will use the Northwind database from Microsoft. In the ! database, we have a products table, and we want to analyze this table by <i>suppliers ! versus product categories</i>. We will place the suppliers on each row, and ! pivot on categories. So from the table on the left, we generate the pivot-table on the right:</p> ! </font> ! <table border="0" cellspacing="2" cellpadding="2" align="center"> ! <tr> ! <td> ! <table border="1" cellspacing="2" cellpadding="2" align="center" width="142"> ! <tr> ! <td><i>Supplier</i></td> ! <td><i>Category</i></td> ! </tr> ! <tr> ! <td>supplier1</td> ! <td>category1</td> ! </tr> ! <tr> ! <td>supplier2</td> ! <td>category1</td> ! </tr> ! <tr> ! <td>supplier3</td> ! <td>category2</td> ! </tr> ! </table> ! </td> ! <td> <font face="Courier New, Courier, mono">--></font></td> ! <td> ! <table border="1" cellspacing="2" cellpadding="2" align="center"> ! <tr> ! <td> </td> ! <td><i>category1</i></td> ! <td><i>category2</i></td> ! <td><i>total</i></td> ! </tr> ! <tr> ! <td><i>supplier1</i></td> ! <td align="right">1</td> ! <td align="right">0</td> ! <td align="right">1</td> ! </tr> ! <tr> ! <td><i>supplier2</i></td> ! <td align="right">1</td> ! <td align="right">1</td> ! <td align="right">2</td> ! </tr> ! </table> ! </td> ! </tr> ! </table> ! <font color="#000000"> ! <p>The following code will generate the SQL for a cross-tabulation: ! <pre> ! # Query the main "product" table ! # Set the rows to CompanyName ! # and the columns to the values of Categories ! # and define the joins to link to lookup tables ! # "categories" and "suppliers" ! # ! include "adodb/pivottable.php"; ! $sql = PivotTableSQL( ! $gDB, # adodb connection ! 'products p ,categories c ,suppliers s', # tables ! 'CompanyName', # rows (multiple fields allowed) ! 'CategoryName', # column to pivot on ! 'p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID' # joins/where ! ); ! </pre> ! </font> ! <p><font color="#000000"> This will generate the following SQL:</font></p> ! <p><code><font size="2">SELECT CompanyName, <br> ! SUM(CASE WHEN CategoryName='Beverages' THEN 1 ELSE 0 END) AS "Beverages", ! <br> ! SUM(CASE WHEN CategoryName='Condiments' THEN 1 ELSE 0 END) AS "Condiments", ! <br> ! SUM(CASE WHEN CategoryName='Confections' THEN 1 ELSE 0 END) AS "Confections", ! <br> ! SUM(CASE WHEN CategoryName='Dairy Products' THEN 1 ELSE 0 END) AS "Dairy ! Products", <br> ! SUM(CASE WHEN CategoryName='Grains/Cereals' THEN 1 ELSE 0 END) AS "Grains/Cereals", ! <br> ! SUM(CASE WHEN CategoryName='Meat/Poultry' THEN 1 ELSE 0 END) AS "Meat/Poultry", ! <br> ! SUM(CASE WHEN CategoryName='Produce' THEN 1 ELSE 0 END) AS "Produce", ! <br> ! SUM(CASE WHEN CategoryName='Seafood' THEN 1 ELSE 0 END) AS "Seafood", ! <br> ! SUM(1) as Total <br> ! FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID ! and s.SupplierID= p.SupplierID <br> ! GROUP BY CompanyName,QuantityPerUnit</font></code></p> ! <p> You can also pivot on <i>numerical columns</i> and <i>generate totals</i> ! by using ranges. The second example shows this:</p> ! <pre> ! $sql = PivotTableSQL( ! $gDB, # adodb connection ! 'products p ,categories c ,suppliers s', # tables ! 'CompanyName', #<font color="#000000"> rows (multiple fields allowed)</font> ! array( # column ranges ! ' 0 ' => 'UnitsInStock <= 0', ! "1 to 5" => '0 < UnitsInStock and UnitsInStock <= 5', ! "6 to 10" => '5 < UnitsInStock and UnitsInStock <= 10', ! "11 to 15" => '10 < UnitsInStock and UnitsInStock <= 15', ! "16+" =>'15 < UnitsInStock' ! ), ! ' p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID', # joins/where ! 'UnitsInStock', # sum this field ! 'Sum' # sum label prefix ! ); ! </pre> ! <p>Which generates: </p> ! <p> <code> <font size="2">SELECT CompanyName, <br> ! SUM(CASE WHEN UnitsInStock <= 0 THEN 1 ELSE 0 END) AS " 0 ", <br> ! SUM(CASE WHEN UnitsInStock <= 0 THEN UnitsInStock ELSE 0 END) AS "Sum ! 0 ", <br> ! SUM(CASE WHEN 0 < UnitsInStock and UnitsInStock <= 5 THEN 1 ELSE 0 END) ! AS "1 to 5", <br> ! SUM(CASE WHEN 0 < UnitsInStock and UnitsInStock <= 5 THEN UnitsInStock ! ELSE 0 END) AS "Sum 1to 5", <br> ! SUM(CASE WHEN 5 < UnitsInStock and UnitsInStock <= 10 THEN 1 ELSE 0 END) ! AS "6 to 10", <br> ! SUM(CASE WHEN 5 < UnitsInStock and UnitsInStock <= 10 THEN UnitsInStock ! ELSE 0 END) AS "Sum 6 to 10", <br> ! SUM(CASE WHEN 10 < UnitsInStock and UnitsInStock <= 15 THEN 1 ELSE 0 END) ! AS "11 to 15", <br> ! SUM(CASE WHEN 10 < UnitsInStock and UnitsInStock <= 15 THEN UnitsInStock ! ELSE 0 END) AS "Sum _11 to 15", <br> ! SUM(CASE WHEN 15 < UnitsInStock THEN 1 ELSE 0 END) AS "16+", <br> ! SUM(CASE WHEN 15 < UnitsInStock THEN UnitsInStock ELSE 0 END) AS "Sum ! 16+", <br> ! SUM(1) as Total <br> ! FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID ! and s.SupplierID= p.SupplierID <br> ! GROUP BY CompanyName,QuantityPerUnit</font></code><font size="2"><br> ! </font> </p> ! <font color="#000000"><hr> <h1>Class Reference<a name="Ref"></a></h1> <p>Function parameters with [ ] around them are optional.</p> ! </font> <h2>Global Variables</h2> <h3>$ADODB_COUNTRECS</h3> *************** *** 1109,1112 **** --- 1255,1260 ---- in connects as the SID for the oci8 driver. Defaults to false. Useful for Oracle 8.0.5 and earlier.</p> + <p><b>autoRollback</b>: Persistent connections are auto-rollbacked in PConnect( + ) if this is set to true. Default is false.</p> <hr> <h3>ADOConnection Main Functions</h3> *************** *** 1137,1143 **** and password $<b>password</b>. If the server supports multiple databases, connect to database $<b>database</b>.</p> ! <p>We now perform a rollback on persistent connection for selected databases since 2.21, as advised in ! the PHP manual. See change log or source code for which databases are affected. <p>Returns true/false depending on connection. See Connect( ) above for more info.</p> <p><b>Execute<a name="Execute"></a>($sql,$inputarr=false)</b></p> <p>Execute SQL statement $<b>sql</b> and return derived class of ADORecordSet --- 1285,1304 ---- and password $<b>password</b>. If the server supports multiple databases, connect to database $<b>database</b>.</p> ! <p>We now perform a rollback on persistent connection for selected databases since ! 2.21, as advised in the PHP manual. See change log or source code for which ! databases are affected. <p>Returns true/false depending on connection. See Connect( ) above for more info.</p> + <p>Since ADOdb 2.21, we also support autoRollback. If you set:</p> + </font> + <pre> $conn = &NewADOConnection('mysql'); + $conn->autoRollback = true; # default is false + $conn->PConnect(...); # rollback here</pre> + <p> Then when doing a persistent connection with PConnect( ), ADOdb will + perform a rollback first. This is because it is documented that PHP is + not guaranteed to rollback existing failed transactions when + persistent connections are used. This is implemented in Oracle, + MySQL, PgSQL, MSSQL, ODBC currently. + </p> + <font color="#000000"> <p><b>Execute<a name="Execute"></a>($sql,$inputarr=false)</b></p> <p>Execute SQL statement $<b>sql</b> and return derived class of ADORecordSet *************** *** 1229,1233 **** <p>Since 1.80, $secs2cache has been optional, and you can define the caching time in $connection->cacheSecs.</p> ! </font> <pre><font color="#000000"> $conn->Connect(...); $conn->cacheSecs = 3600*24; // cache 24 hours --- 1390,1394 ---- <p>Since 1.80, $secs2cache has been optional, and you can define the caching time in $connection->cacheSecs.</p> ! </font> <pre><font color="#000000"> $conn->Connect(...); $conn->cacheSecs = 3600*24; // cache 24 hours *************** *** 1438,1443 **** --- 1599,1610 ---- array. The recordset is discarded for you automatically. If an error occurs, false is returned.</font></p> + <p><b>GetCol<a name="getcol"></a>($sql)</b></p> + + <p><font color="#000000">Executes the SQL and returns all elements of the first column as a + 1-dimensional array. The recordset is discarded for you automatically. If an error occurs, + false is returned.</font></p> <p><font color="#000000"><b>CacheGetOne<a name="cachegetone"></a>([$secs2cache,] $sql), CacheGetRow<a name="cachegetrow"></a>([$secs2cache,] $sql), CacheGetAll<a name="cachegetall"></a>([$secs2cache,] + $sql), CacheGetCol<a name="cachegetcol"></a>([$secs2cache,] $sql)</b></font></p> <font color="#000000"> *************** *** 1489,1493 **** <pre><font color="green"># For oracle, Prepare and PrepareSP are identical</font> $stmt = $db->PrepareSP( ! <font color="#993300">"declare RETVAL integer; <br> begin <br> :RETVAL := </font><font color="#993300">SP_RUNSOMETHING</font><font color="#993300">(:myid,:group); <br> end;"</font>);<br>$db->Parameter($stmt,$id,'myid');<br>$db->Parameter($stmt,$group,'group',false,64); $db->Parameter($stmt,$ret,'RETVAL',true);<br>$db->Execute($stmt); </pre> --- 1656,1660 ---- <pre><font color="green"># For oracle, Prepare and PrepareSP are identical</font> $stmt = $db->PrepareSP( ! <font color="#993300">"declare RETVAL integer; <br> begin <br> :RETVAL := </font><font color="#993300">SP_RUNSOMETHING</font><font color="#993300">(:myid,:group); <br> end;"</font>);<br>$db->Parameter($stmt,$id,'myid');<br>$db->Parameter($stmt,$group,'group',false,64); $db->Parameter($stmt,$ret,'RETVAL',true);<br>$db->Execute($stmt); </pre> *************** *** 1667,1674 **** <p>Menu Example 1: <code>GetMenu('menu1','A',true)</code> will generate a menu: <select name='menu1'> ! <option> ! <option value=1 selected>A ! <option value=2>B ! <option value=3>C </select> for the data (A,1), (B,2), (C,3). Also see <a href="#ex5">example 5</a>.</p> --- 1834,1841 ---- <p>Menu Example 1: <code>GetMenu('menu1','A',true)</code> will generate a menu: <select name='menu1'> ! <option> ! <option value=1 selected>A ! <option value=2>B ! <option value=3>C </select> for the data (A,1), (B,2), (C,3). Also see <a href="#ex5">example 5</a>.</p> *************** *** 1676,1682 **** will generate a menu with both A and B selected: <br> <select name='menu1' multiple size=3> ! <option value=1 selected>A ! <option value=2 selected>B ! <option value=3>C </select> <p> <b>GetMenu2<a name="GetMenu2"></a>($name, [$default_str=''], [$blank1stItem=true], --- 1843,1849 ---- will generate a menu with both A and B selected: <br> <select name='menu1' multiple size=3> ! <option value=1 selected>A ! <option value=2 selected>B ! <option value=3>C </select> <p> <b>GetMenu2<a name="GetMenu2"></a>($name, [$default_str=''], [$blank1stItem=true], *************** *** 1723,1727 **** $fld = $conn->OffsetDate(7); // returns "(trunc(sysdate)+7")</font></pre> <pre><font color="#000000"># get date and time that is 60 hours from current date and time ! $fld = $conn->OffsetDate(2.5, $conn->sysTimeStamp); // returns "(sysdate+2.5)"</font> $conn->Execute("UPDATE TABLE SET dodate=$fld WHERE ID=$id");</pre> --- 1890,1894 ---- $fld = $conn->OffsetDate(7); // returns "(trunc(sysdate)+7")</font></pre> <pre><font color="#000000"># get date and time that is 60 hours from current date and time ! $fld = $conn->OffsetDate(2.5, $conn->sysTimeStamp); // returns "(sysdate+2.5)"</font> $conn->Execute("UPDATE TABLE SET dodate=$fld WHERE ID=$id");</pre> *************** *** 1989,1993 **** </font> <h2>Change Log<a name="Changes"></a><a name=ChangeLog></a></h2> ! <p><b>2.21 19 July 2002</b></p> <p>New GetCol() and CacheGetCol() from ross#bnw.com that returns the first field as a 1 dim array. <p>We have an empty recordset, but RecordCount() could return -1. Fixed. Reported by "Jonathan Polansky" jonathan#polansky.com. --- 2156,2167 ---- </font> <h2>Change Log<a name="Changes"></a><a name=ChangeLog></a></h2> ! <p><b>2.30 1 Aug 2002</b></p> ! <p>Added pivottable.inc.php. Thanks to daniel.lucazeau#ajornet.com for the original ! concept
View Statistics - Next Notice - Previous Notice
Visit Developer Site - Browse CVS Repository |
Syndicate via backend.rss (max. once per hour please) | Powered by CVSNotice 0.1.3 |