SourceForge logo
SourceForge logo
Menu

phpwiki-checkins

Update of /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30035/backend
Modified Files:
	ADODB_mysql.php ADODB.php 
Log Message:
move mysql-specifics into its special class
Index: ADODB_mysql.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend/ADODB_mysql.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -2 -b -p -d -r1.15 -r1.16
--- ADODB_mysql.php	10 Apr 2005 10:43:25 -0000	1.15
+++ ADODB_mysql.php	31 Oct 2005 16:48:22 -0000	1.16
@@ -152,4 +152,75 @@ extends WikiDB_backend_ADODB
 }
 
+ function _get_pageid($pagename, $create_if_missing = false) {
+
+ // check id_cache
+ global $request;
+ $cache =& $request->_dbi->_cache->_id_cache;
+ if (isset($cache[$pagename])) {
+ if ($cache[$pagename] or !$create_if_missing) {
+ return $cache[$pagename];
+ }
+ }
+ 
+ $dbh = &$this->_dbh;
+ $page_tbl = $this->_table_names['page_tbl'];
+ $query = sprintf("SELECT id FROM $page_tbl WHERE pagename=%s",
+ $dbh->qstr($pagename));
+ if (! $create_if_missing ) {
+ $row = $dbh->GetRow($query);
+ return $row ? $row[0] : false;
+ }
+ $row = $dbh->GetRow($query);
+ if (! $row ) {
+	 // have auto-incrementing, atomic version
+	 $rs = $dbh->Execute(sprintf("INSERT INTO $page_tbl"
+					. " (id,pagename)"
+					. " VALUES(NULL,%s)",
+					$dbh->qstr($pagename)));
+	 $id = $dbh->_insertid();
+ } else {
+ $id = $row[0];
+ }
+ assert($id);
+ return $id;
+ }
+
+ /**
+ * Create a new revision of a page.
+ */
+ function set_versiondata($pagename, $version, $data) {
+ $dbh = &$this->_dbh;
+ $version_tbl = $this->_table_names['version_tbl'];
+ 
+ $minor_edit = (int) !empty($data['is_minor_edit']);
+ unset($data['is_minor_edit']);
+ 
+ $mtime = (int)$data['mtime'];
+ unset($data['mtime']);
+ assert(!empty($mtime));
+
+ @$content = (string) $data['%content'];
+ unset($data['%content']);
+ unset($data['%pagedata']);
+ 
+ $this->lock(array('page','recent','version','nonempty'));
+ $dbh->BeginTrans( );
+ $dbh->CommitLock($version_tbl);
+ $id = $this->_get_pageid($pagename, true);
+ $backend_type = $this->backendType();
+ // optimize: mysql can do this with one REPLACE INTO.
+	$rs = $dbh->Execute(sprintf("REPLACE INTO $version_tbl"
+				 . " (id,version,mtime,minor_edit,content,versiondata)"
+				 . " VALUES(%d,%d,%d,%d,%s,%s)",
+				 $id, $version, $mtime, $minor_edit,
+				 $dbh->qstr($content),
+				 $dbh->qstr($this->_serialize($data))));
+ $this->_update_recent_table($id);
+ $this->_update_nonempty_table($id);
+ if ($rs) $dbh->CommitTrans( );
+ else $dbh->RollbackTrans( );
+ $this->unlock(array('page','recent','version','nonempty'));
+ }
+ 
 };
 
Index: ADODB.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend/ADODB.php,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -2 -b -p -d -r1.81 -r1.82
--- ADODB.php	10 Oct 2005 19:42:14 -0000	1.81
+++ ADODB.php	31 Oct 2005 16:48:22 -0000	1.82
@@ -3,5 +3,5 @@ rcs_id('$Id$');
 
 /*
- Copyright 2002,2004 $ThePhpWikiProgrammingTeam
+ Copyright 2002,2004,2005 $ThePhpWikiProgrammingTeam
 
 This file is part of PhpWiki.
@@ -27,5 +27,5 @@ rcs_id('$Id$');
 * @author: Lawrence Akka, Reini Urban
 *
- * Now (phpwiki-1.3.10) with adodb-4.22, by Reini Urban:
+ * Now (since phpwiki-1.3.10) with adodb-4.22, by Reini Urban:
 * 1) Extended to use all available database backends, not only mysql.
 * 2) It uses the ultra-fast binary adodb extension if loaded.
@@ -246,5 +246,5 @@ extends WikiDB_backend
 . " SET hits=?, pagedata=?"
 . " WHERE pagename=?",
- array($hits, $this->_serialize($data),$pagename))) {
+ array($hits, $this->_serialize($data), $pagename))) {
 $dbh->CommitTrans( );
 return true;
@@ -294,13 +294,4 @@ extends WikiDB_backend
 $row = $dbh->GetRow($query);
 if (! $row ) {
- //mysql, mysqli or mysqlt
- if (substr($dbh->databaseType,0,5) == 'mysql') {
- // have auto-incrementing, atomic version
- $rs = $dbh->Execute(sprintf("INSERT INTO $page_tbl"
- . " (id,pagename)"
- . " VALUES(NULL,%s)",
- $dbh->qstr($pagename)));
- $id = $dbh->_insertid();
- } else {
 //$id = $dbh->GenID($page_tbl . 'seq');
 // Better generic version than with adodob::genID
@@ -318,5 +309,4 @@ extends WikiDB_backend
 else $dbh->RollbackTrans( );
 $this->unlock(array('page'));
- }
 } else {
 $id = $row[0];
@@ -451,13 +441,4 @@ extends WikiDB_backend
 $id = $this->_get_pageid($pagename, true);
 $backend_type = $this->backendType();
- // optimize: mysql can do this with one REPLACE INTO.
- if (substr($backend_type,0,5) == 'mysql') {
- $rs = $dbh->Execute(sprintf("REPLACE INTO $version_tbl"
- . " (id,version,mtime,minor_edit,content,versiondata)"
- . " VALUES(%d,%d,%d,%d,%s,%s)",
- $id, $version, $mtime, $minor_edit,
- $dbh->qstr($content),
- $dbh->qstr($this->_serialize($data))));
- } else {
 $dbh->Execute(sprintf("DELETE FROM $version_tbl"
 . " WHERE id=%d AND version=%d",
@@ -468,5 +449,4 @@ extends WikiDB_backend
 array($id, $version, $mtime, $minor_edit,
 $content, $this->_serialize($data)));
- }
 $this->_update_recent_table($id);
 $this->_update_nonempty_table($id);
@@ -795,5 +775,5 @@ extends WikiDB_backend
 /*
 function _sql_match_clause($word) {
- //not sure if we need this. ADODB may do it for us
+ //not sure if we need this. ADODB may do it for usand function_exists('pg_escape_bytea')
 $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); 
 
@@ -1457,4 +1437,7 @@ extends WikiDB_backend_search
 
 // $Log$
+// Revision 1.82 2005年10月31日 16:48:22 rurban
+// move mysql-specifics into its special class
+//
 // Revision 1.81 2005年10月10日 19:42:14 rurban
 // fix wanted_pages SQL syntax
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /