Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezsearchlog.php
Go to the documentation of this file.
1 <?php
17 class eZSearchLog
18 {
22 static function addPhrase( $phrase, $returnCount )
23 {
24 $db = eZDB::instance();
25 $db->begin();
26 $db->lock( "ezsearch_search_phrase" );
27
28 $trans = eZCharTransform::instance();
29 $phrase = $trans->transformByGroup( trim( $phrase ), 'search' );
30
31 // 250 is the numbers of characters accepted by the DB table, so shorten to fit
32 if ( strlen( $phrase ) > 250 )
33 {
34 $phrase = substr( $phrase , 0 , 247 ) . "...";
35 }
36 $phrase = $db->escapeString( $phrase );
37
38 // find or store the phrase
39 $phraseRes = $db->arrayQuery( "SELECT id FROM ezsearch_search_phrase WHERE phrase='$phrase'" );
40
41 if ( count( $phraseRes ) == 1 )
42 {
43 $phraseID = $phraseRes[0]['id'];
44 $db->query( "UPDATE ezsearch_search_phrase
45 SET phrase_count = phrase_count + 1,
46 result_count = result_count + $returnCount
47 WHERE id = $phraseID" );
48 }
49 else
50 {
51 $db->query( "INSERT INTO
52 ezsearch_search_phrase ( phrase, phrase_count, result_count )
53 VALUES ( '$phrase', 1, $returnCount )" );
54 }
55 $db->unlock();
56 $db->commit();
57 }
58
62 static function mostFrequentPhraseArray( $parameters = array( ) )
63 {
64 $db = eZDB::instance();
65
66 $query = 'SELECT phrase_count, result_count / phrase_count AS result_count, id, phrase
67 FROM ezsearch_search_phrase
68 ORDER BY phrase_count DESC';
69
70 return $db->arrayQuery( $query, $parameters );
71 }
72
77 static function removeStatistics()
78 {
79 $db = eZDB::instance();
80 $query = "DELETE FROM ezsearch_search_phrase";
81 $db->query( $query );
82 }
83 }
84
85 ?>
eZCharTransform\instance
static instance()
Definition: ezchartransform.php:434
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZSearchLog
eZSearchLog handles logging of search phrases
Definition: ezsearchlog.php:18
eZSearchLog\mostFrequentPhraseArray
static mostFrequentPhraseArray( $parameters=array())
Definition: ezsearchlog.php:62
eZSearchLog\removeStatistics
static removeStatistics()
Definition: ezsearchlog.php:77
eZSearchLog\addPhrase
static addPhrase( $phrase, $returnCount)
Definition: ezsearchlog.php:22
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.