1
freeop
Profile 0.90 Beta / Comments Search module
  • 2007/10/8 19:12

  • freeop

  • Just popping in

  • Posts: 25

  • Since: 2002/4/12


#
# Table structure for table `profiles`
#

CREATE TABLE `profiles` (
  `
id` int(11) NOT NULL auto_increment,
  `
approved` tinyint(4) NOT NULL default '0',
  `
viewable` tinyint(4) NOT NULL default '1',
  `
disabled` tinyint(4) NOT NULL default '0',
  `
uid` int(11) NOT NULL default '0',
  `
cid` int(11) NOT NULL default '0',
  `
name` varchar(50) NOT NULL default '',
  `
image` varchar(255) NOT NULL default '',
  `
uploadimage` varchar(255) NOT NULL default '',
  `
imagechoice` tinyint(4) NOT NULL default '0',
  `
url` varchar(255) NOT NULL default '',
  `
location` varchar(75) NOT NULL default '',
  `
list` varchar(255) NOT NULL default '',
  `
descript` text NOT NULL,
  `
descript2` text,
  `
linkprofile` tinyint(1) NOT NULL default '0',
  
PRIMARY KEY  (`id`)
) 
TYPE=MyISAM COMMENT='Xoops Profiles Module';

# 
# Table structure for table `xoops_profiles_cats`
# 

CREATE TABLE `profiles_cats` (
  `
cid` int(11) NOT NULL auto_increment,
  `
name` varchar(75) NOT NULL default '',
  `
pid` int(11) NOT NULL default '0',
  
UNIQUE KEY `ID` (`cid`)
) 
TYPE=MyISAM COMMENT='Profiles Categories';

function comments_search($queryarray, $andor, $limit, $offset, $userid){
    global 
$xoopsDB;
    
$sql = "SELECT com_id, com_pid, com_rootid, com_modid, com_itemid,  com_created, com_uid, com_title, com_text, com_status FROM ".$xoopsDB->prefix("xoopscomments")." WHERE com_id>0 ";
    if ( 
$userid != 0 ) {
        
$sql .= " AND com_uid=".$userid." ";
    }
    
// because count() returns 1 even if a supplied variable
    // is not an array, we must check if $querryarray is really an array
    
if ( is_array($queryarray) && $count = count($queryarray) ) {
        
$sql .= " AND ((com_title LIKE '%$queryarray[0]%' OR com_text LIKE '%$queryarray[0]%')";
        for(
$i=1;$i<$count;$i++){
            
$sql .= " $andor ";
            
$sql .= "(com_title LIKE '%$queryarray[$i]%' OR com_text LIKE '%$queryarray[$i]%')";
        }
        
$sql .= ") ";
    }
    
$sql .= "ORDER BY com_created DESC";
    
$result = $xoopsDB->query($sql,$limit,$offset);

    
$module_handler =& xoops_gethandler('module');
    
$modules =& $module_handler->getObjects(new Criteria('hascomments', 1), true);

    
$ret = array();
    
$i = 0;
     while(
$myrow = $xoopsDB->fetchArray($result)){

        
$com_id = $myrow[com_id];
        
$com_modid=$myrow[com_modid];
        
$com_pid=$myrow[com_pid];
        
$com_rootid=$myrow[com_rootid];
        
$com_itemid=$myrow[com_itemid];

        
$comment_config = array();
        
$comment_config = $modules[$com_modid]->getInfo('comments'); 
        
        
$link = "../".$modules[$com_modid]->getVar('dirname').'/';
        
$link .= $comment_config['pageName'].'?';
        
$link .= $comment_config['itemName'].'=';
        
$link .= $com_itemid.'&com_id='.$com_id.'&com_rootid='.$com_rootid;
        
$link .= '&com_mode=thread&#comment'.$com_id;
        
        
$ret[$i]['image'] = "img.gif";
        
$ret[$i]['link'] = $link;
        
$ret[$i]['title'] = $myrow['com_title'];
        
$ret[$i]['time'] = $myrow['com_created'];
        
$ret[$i]['uid'] = $myrow['com_uid'];
        
$i++;
    }
    return 
$ret;
}

Well its been a long time....I'm a noob again.. I'm trying to use the comment search to search the <`list` varchar(255)> data in the profiles module.. I'm running out of hair.. I've tried to contact hyperpod via email, phone, Pm and contact. The website will not allow me to register as well.. Is this just to simple for me or what.. Any help would be great..


Sources :
Comments Search Module 1.01
Profiles 0.91b

2
Catzwolf
Re: Profile 0.90 Beta / Comments Search module
  • 2007/10/8 21:16

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


I haven't tested this, but this might work for you:

function comments_search( $queryarray, $andor, $limit, $offset, $userid ) {
    global 
$xoopsDB;
    
$sql = "SELECT a.com_id, a.com_pid, a.com_rootid, a.com_modid, a.com_itemid,  a.com_created, a.com_uid, a.com_title, a.com_text, a.com_status FROM " . $xoopsDB->prefix( "xoopscomments" ) . " AS a WHERE a.com_id>0 ";
    if ( 
$userid != 0 ) {
        
$sql .= " AND a.com_uid=" . $userid . " ";
    } 
    
// because count() returns 1 even if a supplied variable
    // is not an array, we must check if $querryarray is really an array
    
if ( is_array( $queryarray ) && $count = count( $queryarray ) ) {
        
$sql .= " AND (( a.com_title LIKE '%$queryarray[0]%' OR a.com_text LIKE '%$queryarray[0]%')";
        for( 
$i = 1;$i < $count;$i++ ) {
            
$sql .= " $andor ";
            
$sql .= "(a.com_title LIKE '%$queryarray[$i]%' OR a.com_text LIKE '%$queryarray[$i]%')";
        } 
        
$sql .= ") ";
    } 
    
$sql .= "LEFT JOIN c.list ".$xoopsDB->prefix( "profiles" )." AS c.com_list ON c.uid = a.com_uid";
    
$sql .= "ORDER BY com_created DESC";
    
$result = $xoopsDB->query( $sql, $limit, $offset );

    
$module_handler = &xoops_gethandler( 'module' );
    
$modules = &$module_handler->getObjects( new Criteria( 'hascomments', 1 ), true );

    
$ret = array();
    
$i = 0;
    while ( 
$myrow = $xoopsDB->fetchArray( $result ) ) {
        
$com_id = $myrow['com_id'];
        
$com_modid = $myrow['com_modid'];
        
$com_pid = $myrow['com_pid'];
        
$com_rootid = $myrow['com_rootid'];
        
$com_itemid = $myrow['com_itemid'];

        
$comment_config = array();
        
$comment_config = $modules[$com_modid]->getInfo( 'comments' );

        
$link = "../" . $modules[$com_modid]->getVar( 'dirname' ) . '/';
        
$link .= $comment_config['pageName'] . '?';
        
$link .= $comment_config['itemName'] . '=';
        
$link .= $com_itemid . '&com_id=' . $com_id . '&com_rootid=' . $com_rootid;
        
$link .= '&com_mode=thread&#comment' . $com_id;

        
$ret[$i]['image'] = "img.gif";
        
$ret[$i]['link'] = $link;
        
$ret[$i]['title'] = $myrow['com_title'];
        
$ret[$i]['time'] = $myrow['com_created'];
        
$ret[$i]['uid'] = $myrow['com_uid'];
        
$ret[$i]['list'] = $myrow['com_list'];
        
$i++;
    } 
    return 
$ret;
}

3
freeop
Re: Profile 0.90 Beta / Comments Search module
  • 2007/10/8 22:55

  • freeop

  • Just popping in

  • Posts: 25

  • Since: 2002/4/12


First good to see you. I tried to test but no go.. doesn't return any matches. Debug mode as follows :
All errors (4) :
Notice: Only variables should be assigned by reference in file /search.php line 140

Notice: Only variables should be assigned by reference in file /modules/smartfaq/xoops_version.php line 320

Notice: Only variables should be assigned by reference in file /modules/comments/include/search.inc.php line 23

Notice: Only variables should be assigned by reference in file /search.php line 168

Queries (21) :
SELECT a.com_id, a.com_pid, a.com_rootid, a.com_modid, a.com_itemid, a.com_created, a.com_uid, a.com_title, a.com_text, a.com_status FROM xoops2_xoopscomments AS a WHERE a.com_id>0 AND (( a.com_title LIKE '%php%' OR a.com_text LIKE '%php%')) LEFT JOIN c.list xoops2_profiles AS c.com_list ON c.uid = a.com_uidORDER BY com_created DESC LIMIT 0, 5
Error number: 1064
Error message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN c.list xoops2_profiles AS c.com_list ON c.uid = a.com_uidORDER BY com_' at line 1

However gives me something to play with. I'll try to tackle it a bit tomorrow.. Thx Catz..