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` (
  `
idint(11NOT NULL auto_increment,
  `
approvedtinyint(4NOT NULL default '0',
  `
viewabletinyint(4NOT NULL default '1',
  `
disabledtinyint(4NOT NULL default '0',
  `
uidint(11NOT NULL default '0',
  `
cidint(11NOT NULL default '0',
  `
namevarchar(50NOT NULL default '',
  `
imagevarchar(255NOT NULL default '',
  `
uploadimagevarchar(255NOT NULL default '',
  `
imagechoicetinyint(4NOT NULL default '0',
  `
urlvarchar(255NOT NULL default '',
  `
locationvarchar(75NOT NULL default '',
  `
listvarchar(255NOT NULL default '',
  `
descripttext NOT NULL,
  `
descript2text,
  `
linkprofiletinyint(1NOT NULL default '0',
  
PRIMARY KEY  (`id`)
TYPE=MyISAM COMMENT='Xoops Profiles Module';


# Table structure for table `xoops_profiles_cats`


CREATE TABLE `profiles_cats` (
  `
cidint(11NOT NULL auto_increment,
  `
namevarchar(75NOT NULL default '',
  `
pidint(11NOT 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 != ) {
        
$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 != ) {
        
$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'), 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..

Login

Who's Online

221 user(s) are online (152 user(s) are browsing Support Forums)


Members: 0


Guests: 221


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits