From: Reini U. <ru...@us...> - 2007-01-21 23:16:30
|
Update of /cvsroot/phpwiki/phpwiki/lib/wikilens In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7594 Modified Files: RatingsDb.php Log Message: Fix dba with RATING_STORAGE=SQL Index: RatingsDb.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/wikilens/RatingsDb.php,v retrieving revision 1.13 retrieving revision 1.14 diff -u -2 -b -p -d -r1.13 -r1.14 --- RatingsDb.php 10 Oct 2005 19:51:41 -0000 1.13 +++ RatingsDb.php 21 Jan 2007 23:16:29 -0000 1.14 @@ -6,8 +6,7 @@ rcs_id('$Id$'); * * TODO: - * - fix RATING_STORAGE = WIKIPAGE + * - fix RATING_STORAGE = WIKIPAGE (dba, file) * - fix smart caching * - finish mysuggest.c (external engine with data from mysql) - * - add php_prediction from wikilens * - add the various show modes (esp. TopN queries in PHP) */ @@ -25,8 +24,12 @@ rcs_id('$Id$'); */ -//FIXME! for other than SQL backends +// For other than SQL backends. dba + adodb SQL ratings are allowed but deprecated. +// We will probablöy drop this hack. if (!defined('RATING_STORAGE')) - define('RATING_STORAGE', 'SQL'); //TODO: support ADODB + // for DATABASE_TYPE=dba and forced RATING_STORAGE=SQL we must use ADODB, + // but this is problematic. + define('RATING_STORAGE', $GLOBALS['request']->_dbi->_backend->isSQL() ? 'SQL' : 'WIKIPAGE'); //define('RATING_STORAGE','WIKIPAGE'); // not fully supported yet + // leave undefined for internal, slow php engine. //if (!defined('RATING_EXTERNAL')) @@ -53,11 +56,15 @@ class RatingsDb extends WikiDB { $this->dimension = null; if (RATING_STORAGE == 'SQL') { + if (isa($this->_backend, 'WikiDB_backend_PearDB')) { $this->_sqlbackend = &$this->_backend; - if (isa($this->_backend, 'WikiDB_backend_PearDB')) $this->dbtype = "PearDB"; - elseif (isa($this->_backend, 'WikiDB_backend_ADODOB')) + } elseif (isa($this->_backend, 'WikiDB_backend_ADODOB')) { + $this->_sqlbackend = &$this->_backend; $this->dbtype = "ADODB"; - else { + } else { include_once("lib/WikiDB/backend/ADODB.php"); + // It is not possible to decouple a ref from the source again. (4.3.11) + // It replaced the main request backend. So we don't initialize _sqlbackend before. + //$this->_sqlbackend = clone($this->_backend); $this->_sqlbackend = new WikiDB_backend_ADODB($GLOBALS['DBParams']); $this->dbtype = "ADODB"; @@ -291,5 +298,5 @@ class RatingsDb extends WikiDB { if (RATING_STORAGE == 'SQL') { - $dbh = &$this->_dbi->_backend; + $dbh = &$this->_sqlbackend; if (isset($pagename)) $page = $dbh->_get_pageid($pagename); @@ -360,5 +367,5 @@ class RatingsDb extends WikiDB { } if (isset($pagename)) { - $raterid = $this->_backend->_get_pageid($pagename, true); + $raterid = $this->_sqlbackend->_get_pageid($pagename, true); $where .= " raterpage=$raterid"; } @@ -460,5 +467,5 @@ class RatingsDb extends WikiDB { } if (isset($rater)) { - $raterid = $this->_backend->_get_pageid($rater, true); + $raterid = $dbi->_get_pageid($rater, true); $where .= " AND raterpage=$raterid"; } @@ -467,5 +474,5 @@ class RatingsDb extends WikiDB { $where .= " AND ("; for($i = 0; $i < count($ratee); $i++){ - $rateeid = $this->_backend->_get_pageid($ratee[$i], true); + $rateeid = $dbi->_get_pageid($ratee[$i], true); $where .= "rateepage=$rateeid"; if($i != (count($ratee) - 1)){ @@ -475,5 +482,5 @@ class RatingsDb extends WikiDB { $where .= ")"; } else { - $rateeid = $this->_backend->_get_pageid($ratee, true); + $rateeid = $dbi->_get_pageid($ratee, true); $where .= " AND rateepage=$rateeid"; } @@ -513,6 +520,6 @@ class RatingsDb extends WikiDB { $dbi->lock(); - $raterid = $this->_backend->_get_pageid($rater, true); - $rateeid = $this->_backend->_get_pageid($ratee, true); + $raterid = $dbi->_get_pageid($rater, true); + $rateeid = $dbi->_get_pageid($ratee, true); $where = "WHERE raterpage=$raterid and rateepage=$rateeid"; if (isset($dimension)) { @@ -546,6 +553,6 @@ class RatingsDb extends WikiDB { $dbi->lock(); - $raterid = $this->_backend->_get_pageid($rater, true); - $rateeid = $this->_backend->_get_pageid($ratee, true); + $raterid = $dbi->_get_pageid($rater, true); + $rateeid = $dbi->_get_pageid($ratee, true); assert($raterid); assert($rateeid); @@ -713,4 +720,7 @@ extends WikiDB_backend_PearDB { // $Log$ +// Revision 1.14 2007/01/21 23:16:29 rurban +// Fix dba with RATING_STORAGE=SQL +// // Revision 1.13 2005/10/10 19:51:41 rurban // fix aesthetic issues by John Stevens |