From: <var...@us...> - 2021-09-01 16:32:46
|
Revision: 10528 http://sourceforge.net/p/phpwiki/code/10528 Author: vargenau Date: 2021-09-01 16:32:44 +0000 (Wed, 01 Sep 2021) Log Message: ----------- PearDB.php: move functions getRow and _sql_set Modified Paths: -------------- trunk/lib/WikiDB/backend/PearDB.php Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2021-09-01 16:12:07 UTC (rev 10527) +++ trunk/lib/WikiDB/backend/PearDB.php 2021-09-01 16:32:44 UTC (rev 10528) @@ -77,6 +77,12 @@ } + /* with one result row */ + function getRow($sql) + { + return $this->_dbh->getRow($sql); + } + /** * Close database connection. */ @@ -207,17 +213,6 @@ else $data[$key] = $val; } - - /* Portability issue -- not all DBMS supports huge strings - * so we need to 'bind' instead of building a simple SQL statment. - * Note that we do not need to escapeSimple when we bind - $dbh->query(sprintf("UPDATE $page_tbl" - . " SET hits=%d, pagedata='%s'" - . " WHERE pagename='%s'", - $hits, - $dbh->escapeSimple($this->_serialize($data)), - $dbh->escapeSimple($pagename))); - */ $dbh->query("UPDATE $page_tbl" . " SET hits=?, pagedata=?" . " WHERE pagename=?", @@ -757,6 +752,15 @@ return "pagename LIKE '%$word%' OR content LIKE '%$word%'"; } + function _sql_set(&$pagenames) + { + $s = '('; + foreach ($pagenames as $p) { + $s .= ("'" . $this->_dbh->escapeSimple($p) . "',"); + } + return substr($s, 0, -1) . ")"; + } + /* * Find highest or lowest hit counts. */ @@ -902,15 +906,6 @@ return new WikiDB_backend_PearDB_generic_iter($this, $result); } - function _sql_set(&$pagenames) - { - $s = '('; - foreach ($pagenames as $p) { - $s .= ("'" . $this->_dbh->escapeSimple($p) . "',"); - } - return substr($s, 0, -1) . ")"; - } - /** * Rename page in the database. * @@ -954,13 +949,13 @@ $this->lock(); $dbh->query("DELETE FROM $recent_tbl" - . ($pageid ? " WHERE id=$pageid" : "")); + . ($pageid ? " WHERE id=$pageid" : "")); $dbh->query("INSERT INTO $recent_tbl" - . " (id, latestversion, latestmajor, latestminor)" - . " SELECT id, $maxversion, $maxmajor, $maxminor" - . " FROM $version_tbl" - . ($pageid ? " WHERE id=$pageid" : "") - . " GROUP BY id"); + . " (id, latestversion, latestmajor, latestminor)" + . " SELECT id, $maxversion, $maxmajor, $maxminor" + . " FROM $version_tbl" + . ($pageid ? " WHERE id=$pageid" : "") + . " GROUP BY id"); $this->unlock(); } @@ -1140,11 +1135,6 @@ return $this->_dbh->connection; } - function getRow($query) - { - return $this->_dbh->getRow($query); - } - function listOfTables() { return $this->_dbh->getListOf('tables'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |