[1011]XOOPS 2.5 模組開發
<?php
function tad_note_search($queryarray, $andor, $limit, $offset, $userid){
global $xoopsDB;
//處理許功蓋
if(get_magic_quotes_gpc()){
foreach($queryarray as $k=>$v){
$arr[$k]=addslashes($v);
}
$queryarray=$arr;
}
$sql = "SELECT `note_sn` , `note_title` , `note_date` , `uid` FROM ".$xoopsDB->prefix("tad_notes")." WHERE `note_public`='1' ";
if ( $userid != 0 ) {
$sql .= " AND uid=".$userid." ";
}
if ( is_array($queryarray) && $count = count($queryarray) ) {
$sql .= " AND ((`note_title` LIKE '%{$queryarray[0]}%' OR `note_content` LIKE '%{$queryarray[0]}%' OR `note_date` LIKE '%{$queryarray[0]}%')";
for($i=1;$i<$count;$i++){
$sql .= " $andor ";
$sql .= "( `note_title` LIKE '%{$queryarray[$i]}%' OR `note_content` LIKE '%{$queryarray[$i]}%' OR `note_date` LIKE '%{$queryarray[$i]}%')";
}
$sql .= ") ";
}
$sql .= "ORDER BY `note_sort` DESC";
$result = $xoopsDB->query($sql,$limit,$offset);
$ret = array();
$i = 0;
while($myrow = $xoopsDB->fetchArray($result)){
$ret[$i]['image'] = "images/note.png";
$ret[$i]['link'] = "view.php?note_sn=".$myrow['note_sn'];
$ret[$i]['title'] = $myrow['note_title'];
$ret[$i]['time'] = strtotime($myrow['note_date']);
$ret[$i]['uid'] = $myrow['uid'];
$i++;
}
return $ret;
}
?>