📄 adodb.php
字号:
// Get phptype and dbsyntax // $str => phptype(dbsyntax) if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { $parsed['phptype'] = $arr[1]; $parsed['dbsyntax'] = !$arr[2] ? $arr[1] : $arr[2]; } else { $parsed['phptype'] = $str; $parsed['dbsyntax'] = $str; } if (!count($dsn)) { return $parsed; } // Get (if found): username and password // $dsn => username:password@protocol+hostspec/database if (($at = strrpos($dsn,'@')) !== false) { $str = substr($dsn, 0, $at); $dsn = substr($dsn, $at + 1); if (($pos = strpos($str, ':')) !== false) { $parsed['username'] = rawurldecode(substr($str, 0, $pos)); $parsed['password'] = rawurldecode(substr($str, $pos + 1)); } else { $parsed['username'] = rawurldecode($str); } } // Find protocol and hostspec // $dsn => proto(proto_opts)/database if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { $proto = $match[1]; $proto_opts = $match[2] ? $match[2] : false; $dsn = $match[3]; // $dsn => protocol+hostspec/database (old format) } else { if (strpos($dsn, '+') !== false) { list($proto, $dsn) = explode('+', $dsn, 2); } if (strpos($dsn, '/') !== false) { list($proto_opts, $dsn) = explode('/', $dsn, 2); } else { $proto_opts = $dsn; $dsn = null; } } // process the different protocol options $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; $proto_opts = rawurldecode($proto_opts); if ($parsed['protocol'] == 'tcp') { if (strpos($proto_opts, ':') !== false) { list($parsed['hostspec'], $parsed['port']) = explode(':', $proto_opts); } else { $parsed['hostspec'] = $proto_opts; } } elseif ($parsed['protocol'] == 'unix') { $parsed['socket'] = $proto_opts; } // Get dabase if any // $dsn => database if ($dsn) { // /database if (($pos = strpos($dsn, '?')) === false) { $parsed['database'] = $dsn; // /database?param1=value1¶m2=value2 } else { $parsed['database'] = substr($dsn, 0, $pos); $dsn = substr($dsn, $pos + 1); if (strpos($dsn, '&') !== false) { $opts = explode('&', $dsn); } else { // database?param1=value1 $opts = array($dsn); } foreach ($opts as $opt) { list($key, $value) = explode('=', $opt); if (!isset($parsed[$key])) { // don't allow params overwrite $parsed[$key] = rawurldecode($value); } } } } return $parsed; }// $Log: ADODB.php,v $// Revision 1.74 2005/02/10 19:04:22 rurban// move getRow up one level to our backend class//// Revision 1.73 2005/02/04 13:43:30 rurban// fix purge cache error//// Revision 1.72 2005/01/29 19:51:03 rurban// Bugs item #1077769 fixed by frugal.// Deleted the wrong page. Fix all other tables also.//// Revision 1.71 2005/01/25 08:01:00 rurban// fix listOfFields with different database//// Revision 1.70 2005/01/18 20:55:43 rurban// reformatting and two bug fixes: adding missing parens//// Revision 1.69 2004/12/26 17:14:03 rurban// fix ADODB MostPopular, avoid limit -1, pass hits on empty data//// Revision 1.68 2004/12/22 18:33:25 rurban// fix page _id_cache logic for _get_pageid create_if_missing//// Revision 1.67 2004/12/22 15:47:41 rurban// fix wrong _update_nonempty_table on empty content (i.e. the new deletePage)//// Revision 1.66 2004/12/13 14:39:16 rurban// avoid warning//// Revision 1.65 2004/12/10 22:15:00 rurban// fix $page->get('_cached_html)// refactor upgrade db helper _convert_cached_html() to be able to call them from WikiAdminUtils also.// support 2nd genericSqlQuery param (bind huge arg)//// Revision 1.64 2004/12/10 02:45:27 rurban// SQL optimization:// put _cached_html from pagedata into a new seperate blob, not huge serialized string.// it is only rarelely needed: for current page only, if-not-modified// but was extracted for every simple page iteration.//// Revision 1.63 2004/12/08 12:55:51 rurban// support new non-destructive delete_page via generic backend method//// Revision 1.62 2004/12/06 19:50:04 rurban// enable action=remove which is undoable and seeable in RecentChanges: ADODB ony for now.// renamed delete_page to purge_page.// enable action=edit&version=-1 to force creation of a new version.// added BABYCART_PATH config// fixed magiqc in adodb.inc.php// and some more docs//// Revision 1.61 2004/11/30 17:45:53 rurban// exists_links backend implementation//// Revision 1.60 2004/11/28 20:42:18 rurban// Optimize PearDB _extract_version_data and _extract_page_data.//// Revision 1.59 2004/11/27 14:39:05 rurban// simpified regex search architecture:// no db specific node methods anymore,// new sql() method for each node// parallel to regexp() (which returns pcre)// regex types bitmasked (op's not yet)// new regex=sql// clarified WikiDB::quote() backend methods:// ->quote() adds surrounsing quotes// ->qstr() (new method) assumes strings and adds no quotes! (in contrast to ADODB)// pear and adodb have now unified quote methods for all generic queries.//// Revision 1.58 2004/11/26 18:39:02 rurban// new regex search parser and SQL backends (90% complete, glob and pcre backends missing)//// Revision 1.57 2004/11/25 17:20:51 rurban// and again a couple of more native db args: backlinks//// Revision 1.56 2004/11/23 13:35:48 rurban// add case_exact search//// Revision 1.55 2004/11/21 11:59:26 rurban// remove final \n to be ob_cache independent//// Revision 1.54 2004/11/20 17:49:39 rurban// add fast exclude support to SQL get_all_pages//// Revision 1.53 2004/11/20 17:35:58 rurban// improved WantedPages SQL backends// PageList::sortby new 3rd arg valid_fields (override db fields)// WantedPages sql pager inexact for performance reasons:// assume 3 wantedfrom per page, to be correct, no getTotal()// support exclude argument for get_all_pages, new _sql_set()//// Revision 1.52 2004/11/17 20:07:17 rurban// just whitespace//// Revision 1.51 2004/11/15 15:57:37 rurban// silent cache warning//// Revision 1.50 2004/11/10 19:32:23 rurban// * optimize increaseHitCount, esp. for mysql.// * prepend dirs to the include_path (phpwiki_dir for faster searches)// * Pear_DB version logic (awful but needed)// * fix broken ADODB quote// * _extract_page_data simplification//// Revision 1.49 2004/11/10 15:29:21 rurban// * requires newer Pear_DB (as the internal one): quote() uses now escapeSimple for strings// * ACCESS_LOG_SQL: fix cause request not yet initialized// * WikiDB: moved SQL specific methods upwards// * new Pear_DB quoting: same as ADODB and as newer Pear_DB.// fixes all around: WikiGroup, WikiUserNew SQL methods, SQL logging//// Revision 1.48 2004/11/09 17:11:16 rurban// * revert to the wikidb ref passing. there's no memory abuse there.// * use new wikidb->_cache->_id_cache[] instead of wikidb->_iwpcache, to effectively// store page ids with getPageLinks (GleanDescription) of all existing pages, which// are also needed at the rendering for linkExistingWikiWord().// pass options to pageiterator.// use this cache also for _get_pageid()// This saves about 8 SELECT count per page (num all pagelinks).// * fix passing of all page fields to the pageiterator.// * fix overlarge session data which got broken with the latest ACCESS_LOG_SQL changes//// Revision 1.47 2004/11/06 17:11:42 rurban// The optimized version doesn't query for pagedata anymore.//// Revision 1.46 2004/11/01 10:43:58 rurban// seperate PassUser methods into seperate dir (memory usage)// fix WikiUser (old) overlarge data session// remove wikidb arg from various page class methods, use global ->_dbi instead// ...//// Revision 1.45 2004/10/14 17:19:17 rurban// allow most_popular sortby arguments//// Revision 1.44 2004/09/06 08:33:09 rurban// force explicit mysql auto-incrementing, atomic version//// Revision 1.43 2004/07/10 08:50:24 rurban// applied patch by Philippe Vanhaesendonck:// pass column list to iterators so we can FETCH_NUM in all cases.// bind UPDATE pramas for huge pagedata.// portable oracle backend//// Revision 1.42 2004/07/09 10:06:50 rurban// Use backend specific sortby and sortable_columns method, to be able to// select between native (Db backend) and custom (PageList) sorting.// Fixed PageList::AddPageList (missed the first)// Added the author/creator.. name to AllPagesBy...// display no pages if none matched.// Improved dba and file sortby().// Use &$request reference//// Revision 1.41 2004/07/08 21:32:35 rurban// Prevent from more warnings, minor db and sort optimizations//// Revision 1.40 2004/07/08 16:56:16 rurban// use the backendType abstraction//// Revision 1.39 2004/07/05 13:56:22 rurban// sqlite autoincrement fix//// Revision 1.38 2004/07/05 12:57:54 rurban// add mysql timeout//// Revision 1.37 2004/07/04 10:24:43 rurban// forgot the expressions//// Revision 1.36 2004/07/03 16:51:06 rurban// optional DBADMIN_USER:DBADMIN_PASSWD for action=upgrade (if no ALTER permission)// added atomic mysql REPLACE for PearDB as in ADODB// fixed _lock_tables typo links => link// fixes unserialize ADODB bug in line 180//// Revision 1.35 2004/06/28 14:45:12 rurban// fix adodb_sqlite to have the same dsn syntax as pear, use pconnect if requested//// Revision 1.34 2004/06/28 14:17:38 rurban// updated DSN parser from Pear. esp. for sqlite//// Revision 1.33 2004/06/27 10:26:02 rurban// oci8 patch by Philippe Vanhaesendonck + some ADODB notes+fixes//// Revision 1.32 2004/06/25 14:15:08 rurban// reduce memory footprint by caching only requested pagedate content (improving most page iterators)//// Revision 1.31 2004/06/16 10:38:59 rurban// Disallow refernces in calls if the declaration is a reference// ("allow_call_time_pass_reference clean").// PhpWiki is now allow_call_time_pass_reference = Off clean,// but several external libraries may not.// In detail these libs look to be affected (not tested):// * Pear_DB odbc// * adodb oracle//// Revision 1.30 2004/06/07 19:31:31 rurban// fixed ADOOB upgrade: listOfFields()//// Revision 1.29 2004/05/12 10:49:55 rurban// require_once fix for those libs which are loaded before FileFinder and// its automatic include_path fix, and where require_once doesn't grok// dirname(__FILE__) != './lib'// upgrade fix with PearDB// navbar.tmpl: remove spaces for IE button alignment//// Revision 1.28 2004/05/06 19:26:16 rurban// improve stability, trying to find the InlineParser endless loop on sf.net//// remove end-of-zip comments to fix sf.net bug #777278 and probably #859628//// Revision 1.27 2004/05/06 17:30:38 rurban// CategoryGroup: oops, dos2unix eol// improved phpwiki_version:// pre -= .0001 (1.3.10pre: 1030.099)// -p1 += .001 (1.3.9-p1: 1030.091)// improved InstallTable for mysql and generic SQL versions and all newer tables so far.// abstracted more ADODB/PearDB methods for action=upgrade stuff:// backend->backendType(), backend->database(),// backend->listOfFields(),// backend->listOfTables(),//// Revision 1.26 2004/04/26 20:44:35 rurban// locking table specific for better databases//// Revision 1.25 2004/04/20 00:06:04 rurban// themable paging support//// Revision 1.24 2004/04/18 01:34:20 rurban// protect most_popular from sortby=mtime//// Revision 1.23 2004/04/16 14:19:39 rurban// updated ADODB notes//// (c-file-style: "gnu")// Local Variables:// mode: php// tab-width: 8// c-basic-offset: 4// c-hanging-comment-ender-p: nil// indent-tabs-mode: nil// End: ?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -