summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2006-02-19 10:09:47 +0000
committerLester Caine <lester@lsces.co.uk>2006-02-19 10:09:47 +0000
commit7e3b1627bc402f5c350bd59c0569c7d4d9ef1ec3 (patch)
treec691a97032ba608b88bc8325d4e9c8ac99c6c1ab
parent5071b54eb181b97220c8b76549d96eba31310662 (diff)
downloadsearch-7e3b1627bc402f5c350bd59c0569c7d4d9ef1ec3.tar.gz
search-7e3b1627bc402f5c350bd59c0569c7d4d9ef1ec3.tar.bz2
search-7e3b1627bc402f5c350bd59c0569c7d4d9ef1ec3.zip
Fix reserved word field names
COUNT - SQL Reserved
-rw-r--r--admin/schema_inc.php2
-rw-r--r--refresh_functions.php12
-rw-r--r--search_lib.php24
-rw-r--r--searchstats_lib.php12
4 files changed, 25 insertions, 25 deletions
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index a7e0ea7..ad4fe5d 100644
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -5,7 +5,7 @@ $tables = array(
'searchindex' => "
searchword C(80) PRIMARY,
content_id I4 PRIMARY,
- count I4 NOTNULL DEFAULT '1',
+ i_count I4 NOTNULL DEFAULT '1',
last_update I4 NOTNULL
",
diff --git a/refresh_functions.php b/refresh_functions.php
index 0b80465..6f5c4f8 100644
--- a/refresh_functions.php
+++ b/refresh_functions.php
@@ -1,6 +1,6 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_search/refresh_functions.php,v 1.18 2006/02/14 19:03:17 squareing Exp $
+ * $Header: /cvsroot/bitweaver/_bit_search/refresh_functions.php,v 1.19 2006/02/19 10:09:47 lsces Exp $
*
* Copyright (c) 2004 bitweaver.org
* Copyright (c) 2003 tikwiki.org
@@ -8,7 +8,7 @@
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
- * $Id: refresh_functions.php,v 1.18 2006/02/14 19:03:17 squareing Exp $
+ * $Id: refresh_functions.php,v 1.19 2006/02/19 10:09:47 lsces Exp $
* @author Luis Argerich (lrargerich@yahoo.com)
* @package search
* @subpackage functions
@@ -115,9 +115,9 @@ function random_refresh_index_blogs() {
if( $gBitSystem->isPackageActive( 'blogs' ) ) {
require_once( BLOGS_PKG_PATH.'BitBlog.php' );
// get random blog
- $cant = $gBitSystem->mDb->getOne("select count(*) from `".BIT_DB_PREFIX."blogs`", array());
+ $cant = $gBitSystem->mDb->getOne("SELECT COUNT(*) FROM `".BIT_DB_PREFIX."blogs`", array());
if($cant > 0) {
- $query = "select `blog_id` from `" . BIT_DB_PREFIX . "blogs`";
+ $query = "SELECT `blog_id` FROM `" . BIT_DB_PREFIX . "blogs`";
$blogId = $gBitSystem->mDb->getOne($query, array(), 1, rand(0, $cant - 1));
refresh_index_blogs($blogId);
}
@@ -128,7 +128,7 @@ function refresh_index_blogs( $pBlogId = 0 ) {
global $gBitSystem;
if( $pBlogId > 0 and $gBitSystem->isPackageActive( 'blogs' ) ) {
require_once( BLOGS_PKG_PATH.'BitBlog.php' );
- $query = "SELECT b.`title`, b.`description`, uu.`login` as `user`, uu.`real_name`
+ $query = "SELECT b.`title`, b.`description`, uu.`login` AS `user`, uu.`real_name`
FROM `".BIT_DB_PREFIX."blogs` b
INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON uu.`user_id` = b.`user_id`
WHERE `blog_id` = " . $pBlogId;
@@ -179,7 +179,7 @@ function insert_index( &$words, $pContentId ) {
if (strlen($key) >= $gBitSystem->getPreference( 'search_min_wordlength') ) {
// todo: stopwords
$query = "INSERT INTO `" . BIT_DB_PREFIX . "searchindex`
- (`content_id`,`searchword`,`count`,`last_update`) values (?,?,?,?)";
+ (`content_id`,`searchword`,`i_count`,`last_update`) values (?,?,?,?)";
$gBitSystem->mDb->query($query, array($pContentId, $key, (int) $value, $now));
}
}
diff --git a/search_lib.php b/search_lib.php
index 9696bdc..dd45d0f 100644
--- a/search_lib.php
+++ b/search_lib.php
@@ -1,6 +1,6 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_search/search_lib.php,v 1.17 2006/02/14 21:53:26 squareing Exp $
+ * $Header: /cvsroot/bitweaver/_bit_search/search_lib.php,v 1.18 2006/02/19 10:09:47 lsces Exp $
*
* Copyright (c) 2004 bitweaver.org
* Copyright (c) 2003 tikwiki.org
@@ -8,7 +8,7 @@
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
- * $Id: search_lib.php,v 1.17 2006/02/14 21:53:26 squareing Exp $
+ * $Id: search_lib.php,v 1.18 2006/02/19 10:09:47 lsces Exp $
* @author Luis Argerich (lrargerich@yahoo.com)
* @package search
*/
@@ -29,12 +29,12 @@ class SearchLib extends BitBase {
$words = preg_split("/\s/", $words);
foreach ($words as $word) {
$word = trim($word);
- $cant = $this->mDb->getOne("select count(*) from `" . BIT_DB_PREFIX .
- "search_stats` where `term`=?", array($word));
+ $cant = $this->mDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX .
+ "search_stats` WHERE `term`=?", array($word));
if ($cant) {
- $query = "update `" . BIT_DB_PREFIX . "search_stats` set `hits`= `hits` + 1 where `term`=?";
+ $query = "UPDATE `" . BIT_DB_PREFIX . "search_stats` SET `hits`= `hits` + 1 WHERE `term`=?";
} else {
- $query = "insert into `" . BIT_DB_PREFIX . "search_stats` (`term`,`hits`) values (?,1)";
+ $query = "INSERT INTO `" . BIT_DB_PREFIX . "search_stats` (`term`,`hits`) VALUES (?,1)";
}
$result = $this->mDb->query($query,array($word));
}
@@ -108,21 +108,21 @@ class SearchLib extends BitBase {
if (!isset($search_max_syllwords)) {
$search_max_syllwords = 100;
}
- $query = "select `searchword`, sum(`count`) as `cnt` from `" . BIT_DB_PREFIX .
- "searchindex` where `searchword` like ? group by `searchword` ORDER BY 2 desc";
+ $query = "SELECT `searchword`, SUM(`i_count`) AS `cnt` FROM `" . BIT_DB_PREFIX .
+ "searchindex` WHERE `searchword` LIKE ? GROUP BY `searchword` ORDER BY 2 desc";
$result = $this->mDb->query($query, array('%' . $syllable . '%'), $search_max_syllwords); // search_max_syllwords: how many different searchwords that contain the syllable are taken into account?. Sortet by number of occurences.
while ($res = $result->fetchRow()) {
$ret[] = $res["searchword"];
}
// cache this long running query
foreach($ret as $searchword) {
- $this->mDb->query("insert into `" . BIT_DB_PREFIX .
- "searchwords` (`syllable`,`searchword`) values (?,?)",
+ $this->mDb->query("INSERT INTO `" . BIT_DB_PREFIX .
+ "searchwords` (`syllable`,`searchword`) VALUES (?,?)",
array($syllable, $searchword), -1, -1);
}
// set lru list parameters
$now = time();
- $this->mDb->query("insert into `" . BIT_DB_PREFIX .
+ $this->mDb->query("INSERT INTO `" . BIT_DB_PREFIX .
"searchsyllable`(`syllable`,`last_used`,`last_updated`) values (?,?,?)",
array($syllable,(int) $now,(int) $now));
@@ -132,7 +132,7 @@ class SearchLib extends BitBase {
list($usec, $sec) = explode(" ", microtime());
srand (ceil($sec + 100 * $usec));
if(rand(1, $search_lru_purge_rate) == 1) {
- $lrulength = $this->mDb->getOne("select count(*) from `" . BIT_DB_PREFIX .
+ $lrulength = $this->mDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX .
"searchsyllable`", array());
if ($lrulength > $search_lru_length) { // only purge if lru list is too long.
//purge oldest
diff --git a/searchstats_lib.php b/searchstats_lib.php
index 21a79a3..cec416c 100644
--- a/searchstats_lib.php
+++ b/searchstats_lib.php
@@ -1,6 +1,6 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_search/searchstats_lib.php,v 1.5 2006/02/08 08:24:20 lsces Exp $
+ * $Header: /cvsroot/bitweaver/_bit_search/searchstats_lib.php,v 1.6 2006/02/19 10:09:47 lsces Exp $
*
* Copyright (c) 2004 bitweaver.org
* Copyright (c) 2003 tikwiki.org
@@ -8,7 +8,7 @@
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
- * $Id: searchstats_lib.php,v 1.5 2006/02/08 08:24:20 lsces Exp $
+ * $Id: searchstats_lib.php,v 1.6 2006/02/19 10:09:47 lsces Exp $
* @author Luis Argerich (lrargerich@yahoo.com)
* @package search
*/
@@ -22,22 +22,22 @@ class SearchStatsLib extends BitBase {
}
function clear_search_stats() {
- $query = "delete from `".BIT_DB_PREFIX."search_stats";
+ $query = "DELETE FROM `".BIT_DB_PREFIX."search_stats";
$result = $this->mDb->query($query,array());
}
function list_search_stats($offset, $max_records, $sort_mode, $find) {
if ($find) {
- $mid = " where (UPPER(`term`) like ?)";
+ $mid = " WHERE (UPPER(`term`) LIKE ?)";
$bindvars = array("%".strtoupper( $find )."%");
} else {
$mid = "";
$bindvars = array();
}
- $query = "select * from `".BIT_DB_PREFIX."search_stats` $mid order by ".$this->mDb->convert_sortmode($sort_mode);
- $query_cant = "select count(*) from `".BIT_DB_PREFIX."search_stats` $mid";
+ $query = "SELECT * FROM `".BIT_DB_PREFIX."search_stats` $mid ORDER BY ".$this->mDb->convert_sortmode($sort_mode);
+ $query_cant = "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."search_stats` $mid";
$result = $this->mDb->query($query,$bindvars,$max_records,$offset);
$cant = $this->mDb->getOne($query_cant,$bindvars);
$ret = array();