PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Prohits/analyst/search.php

http://prohits.googlecode.com/
PHP | 542 lines | 471 code | 27 blank | 44 comment | 38 complexity | 4040f7476178002e843858a19ceedf6a MD5 | raw file
  1. <?
  2. /***********************************************************************
  3. Copyright 2010 Gingras and Tyers labs,
  4. Samuel Lunenfeld Research Institute, Mount Sinai Hospital.
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. *************************************************************************/
  15. $theaction = '';
  16. $searchThis = '';
  17. $frm_addwildcard = '';
  18. $limit = 3000;
  19. $bait_search = true;
  20. $hit_search = true;
  21. $band_search = true;
  22. $rawfile_search = true;
  23. $bait_selected_bait_arr = array();
  24. $hit_selected_bait_arr = array();
  25. $TPP_hit_selected_bait_arr = array();
  26. $hit_selected_band_arr = array();
  27. $TPP_hit_selected_band_arr = array();
  28. $band_selected_band_arr = array();
  29. $raw_file_searched_arr = array();
  30. $task_searched_arr = array();
  31. $theaction = '';
  32. $like_str = '';
  33. $GeneID_str = '';
  34. $s_wildcard = '';
  35. $e_wildcard = '';
  36. $geneID_str = '';
  37. $SQL_bait = '';
  38. $msg_h = '';
  39. $add_process_img = 1;
  40. require("../common/site_permission.inc.php");
  41. include("common_functions.inc.php");
  42. require("../common/common_fun.inc.php");
  43. $proteinDB = new mysqlDB(PROHITS_PROTEINS_DB);
  44. $managerDB = new mysqlDB(MANAGER_DB);
  45. require("site_header.php");
  46. $frm_search_OrAnd = 'OR';
  47. $s_wildcard = '%';
  48. $e_wildcard = '%';
  49. //bait search---------------------------------------------------------
  50. if($searchThis){
  51. $searchThis = trim($searchThis);
  52. $searchThis = preg_replace("/[ ]+/", " ", $searchThis);
  53. $searchThis = mysql_escape_string($searchThis);
  54. $like_str = '';
  55. $bait_selected_bait_str = '';
  56. $bait_selected_bait_num = 0;
  57. $field_arr = array("GeneID","LocusTag","GeneName","BaitAcc","Tag","Mutation","Clone","Vector");
  58. $like_str = get_like_str($field_arr,$searchThis);
  59. if($like_str){
  60. $SQL = "SELECT ID FROM Bait WHERE ProjectID='$AccessProjectID' and (" . $like_str .")";
  61. //echo $SQL;exit;
  62. $bait_arr = $HITSDB->fetchAll($SQL);
  63. if(!$bait_arr){
  64. $bait_search = false;
  65. }else{
  66. foreach($bait_arr as $value){
  67. array_push($bait_selected_bait_arr, $value['ID']);
  68. }
  69. }
  70. }
  71. }
  72. //print_r($bait_selected_bait_arr);exit;
  73. //hits search---------------------------------------------------------
  74. $hit_value_for_bait_arr = array();
  75. $hit_value_for_band_arr = array();
  76. $tpp_hit_value_for_bait_arr = array();
  77. $tpp_hit_value_for_band_arr = array();
  78. if($searchThis){
  79. $hit_selected_bait_str = '';
  80. $hits_selected_bait_num = 0;
  81. $geneID_str = '';
  82. $geneID_str_ens = '';
  83. $selected_bait_gene_str = '';
  84. //search all gene IDs
  85. $like_str = get_like_str(array("GeneName"),$searchThis);
  86. $SQL_ens = "SELECT ENSG FROM `Protein_ClassENS` WHERE $like_str";
  87. $results = mysql_query($SQL_ens, $proteinDB->link);
  88. if(mysql_num_rows($results) > $limit){
  89. $like_str_tmp = get_like_str(array("GeneName"),$searchThis, '=');
  90. $SQL_ens = "SELECT ENSG FROM `Protein_ClassENS` WHERE $like_str_tmp";
  91. $results = mysql_query($SQL_ens, $proteinDB->link);
  92. //$msg_h = "More than $limit gene names are matched the search. The exact phrase search is used.";
  93. }
  94. while($row = mysql_fetch_row($results)){
  95. $selected_bait_gene_str .= ",'".$row[0]."'";
  96. }
  97. $SQL_g = "SELECT EntrezGeneID FROM `Protein_Class` WHERE $like_str";
  98. //echo $SQL_g;
  99. $results = mysql_query($SQL_g, $proteinDB->link);
  100. if(mysql_num_rows($results) > $limit){
  101. $like_str_tmp = get_like_str(array("GeneName"),$searchThis, '=');
  102. $SQL_g = "SELECT EntrezGeneID FROM `Protein_Class` WHERE $like_str_tmp";
  103. $results = mysql_query($SQL_g, $proteinDB->link);
  104. $msg_h = "<br>More than $limit gene names are matched. \"The exact phrase\" gene name search is used for hits search.";
  105. }
  106. while($row = mysql_fetch_row($results)){
  107. $selected_bait_gene_str .= ",'".$row[0]."'";
  108. }
  109. //echo "H2: $SQL_g<br>\n";
  110. //from seached GeneIDs get bait IDs from hits results
  111. if($selected_bait_gene_str){
  112. $selected_bait_gene_str = substr($selected_bait_gene_str, 1);
  113. $SQL = "SELECT B.ID, H.BandID, H.Expect, H.Expect2, H.Pep_num, H.SearchEngine from Hits H, Bait B
  114. WHERE B.ID=H.BaitID and B.ProjectID='$AccessProjectID' and H.GeneID in($selected_bait_gene_str)
  115. ORDER BY B.ID, H.Pep_num desc";
  116. $TPP_SQL = "SELECT B.ID, H.BandID, H.PROBABILITY, H.TOTAL_NUMBER_PEPTIDES, H.SearchEngine from TppProtein H, Bait B
  117. WHERE B.ID=H.BaitID and B.ProjectID='$AccessProjectID' and H.GeneID in($selected_bait_gene_str)
  118. Order by B.ID, H.TOTAL_NUMBER_PEPTIDES desc";
  119. //echo "H3: $SQL<br>\n";
  120. //echo "H4: $TPP_SQL<br>\n";
  121. $results = mysql_query($SQL, $HITSDB->link);
  122. while($row = mysql_fetch_row($results)){
  123. array_push($hit_selected_bait_arr, $row[0]);
  124. array_push($hit_selected_band_arr, $row[1]);
  125. if(!isset($hit_value_for_bait_arr[$row[0]])){
  126. $tmp_expect = ($row[2])?$row[2]:$row[3];
  127. $hit_value_for_bait_arr[$row[0]]= $row[5] ." " . $tmp_expect ." / ". $row[4];
  128. }
  129. if(!isset($hit_value_for_band_arr[$row[1]])){
  130. $hit_value_for_band_arr[$row[1]]= $row[5] ." " . $tmp_expect ." / ". $row[4];
  131. }
  132. }
  133. $TPP_results = mysql_query($TPP_SQL, $HITSDB->link);
  134. while($row = mysql_fetch_row($TPP_results)){
  135. array_push($TPP_hit_selected_bait_arr, $row[0]);
  136. array_push($TPP_hit_selected_band_arr, $row[1]);
  137. if(!isset($tpp_hit_value_for_bait_arr[$row[0]])){
  138. $tpp_hit_value_for_bait_arr[$row[0]]= $row[4] ."TPP " . $row[2] ." / ". $row[3];
  139. }
  140. if(!isset($tpp_hit_value_for_band_arr[$row[1]])){
  141. $tpp_hit_value_for_band_arr[$row[1]]= $row[4] ."TPP " . $row[2] ." / ". $row[3];
  142. }
  143. }
  144. }
  145. $hit_selected_bait_arr = array_unique($hit_selected_bait_arr);
  146. $hit_selected_band_arr = array_unique($hit_selected_band_arr);
  147. $TPP_hit_selected_bait_arr = array_unique($TPP_hit_selected_bait_arr);
  148. $TPP_hit_selected_band_arr = array_unique($TPP_hit_selected_band_arr);
  149. if(!$hit_selected_bait_arr){
  150. $hit_search = false;
  151. }
  152. }
  153. //search sample ----------------------------------------------------
  154. $SQL = "SELECT `ID` FROM `Band` WHERE `ProjectID`='$AccessProjectID'";
  155. if($searchThis){
  156. $like_str = get_like_str(array("Location"),$searchThis);
  157. $SQL .= " AND (". $like_str .")";
  158. }
  159. //echo "Band: $SQL<br>\n";
  160. if($band_search){
  161. $results = mysql_query($SQL, $HITSDB->link);
  162. while($row = mysql_fetch_row($results)){
  163. array_push($band_selected_band_arr, $row[0]);
  164. }
  165. }
  166. //========
  167. $raw_file_num = 0;
  168. $task_num = 0;
  169. $msTable_arr = array();
  170. $pro_access_ID_str = '';
  171. if($searchThis){
  172. //get access id string
  173. if($USER->Type == 'Admin'){
  174. $sql_p = "SELECT P.ID, P.Name FROM Projects P order by P.ID";
  175. }else{
  176. $sql_p = "SELECT P.ID, P.Name FROM Projects P, ProPermission M where P.ID=M.ProjectID and M.UserID=$USER->ID order by P.ID";
  177. }
  178. $results = mysql_query($sql_p, $PROHITSDB->link);
  179. while($row = mysql_fetch_row($results)){
  180. if($pro_access_ID_str) $pro_access_ID_str .= ",";
  181. $pro_access_ID_str .= $row[0];
  182. }
  183. //get all ms tables
  184. $SQL = "SHOW TABLES";
  185. $results = mysql_query($SQL, $managerDB->link);
  186. while($row = mysql_fetch_row($results)){
  187. array_push($msTable_arr, $row[0]);
  188. }
  189. //search raw file ---------------------------------------------
  190. $tableName = '';
  191. $SQL_from = '';
  192. $SQL_where = ' WHERE';
  193. $like_str = get_like_str(array("FileName"),$searchThis);
  194. $SQL_where .= " (". $like_str .")";
  195. $SQL_where .= " AND ProjectID in($pro_access_ID_str)";
  196. foreach($BACKUP_SOURCE_FOLDERS as $baseTable => $var_arr){
  197. if(!in_array($baseTable, $msTable_arr)) continue;
  198. $raw_file_searched_arr[$baseTable] = array();
  199. $SQL = "SELECT ID From `".$baseTable."`". $SQL_where;
  200. $results = mysql_query($SQL, $managerDB->link);
  201. while($row = mysql_fetch_row($results)){
  202. array_push($raw_file_searched_arr[$baseTable], $row[0]);
  203. $raw_file_num++;
  204. }
  205. //echo "RawFile : $SQL<br>\n";
  206. //print_r($raw_file_searched_arr[$baseTable]);
  207. }
  208. if(!$raw_file_num) $rawfile_search = false;
  209. }else{
  210. $rawfile_search = false;
  211. }
  212. //---display search results --------------------------------------
  213. ?>
  214. <STYLE type="text/css">
  215. td { font-family : Arial, Helvetica, sans-serif; FONT-SIZE: 10pt;}
  216. .st1 {
  217. display: block;
  218. border: black solid 1px;
  219. width:552;
  220. color: black;
  221. background-color: white;
  222. }
  223. </STYLE>
  224. <script type="text/javascript">
  225. function browse_for_detail(theURL, theTitle, id_str, id_vl_str, theTable){
  226. var theForm = document.getElementById('searched_form');
  227. theForm.title_lable.value=theTitle;
  228. theForm.table.value=theTable;
  229. theForm.searched_id_str.value=document.getElementById(id_str).value;
  230. if(id_vl_str){
  231. theForm.searched_id_vl_str.value=document.getElementById(id_vl_str).value;
  232. }
  233. theForm.action = theURL;
  234. theForm.submit();
  235. }
  236. </script>
  237. <form id="searched_form" name="searched_form" method='post' action="">
  238. <input type=hidden name='title_lable' id='title_lable' value=''>
  239. <input type=hidden name='searched_id_str' id='searched_id_str' value=''>
  240. <input type=hidden name='searched_id_vl_str' id='searched_id_vl_str' value=''>
  241. <input type=hidden name='theaction' id='theaction' value='search'>
  242. <input type=hidden name='table' id='table' value=''>
  243. <table border="0" cellpadding="0" cellspacing="0" width="95%">
  244. <tr>
  245. <td align="left"><br>
  246. &nbsp; <font color="navy" face="helvetica,arial,futura" size="5"><b>Search Results
  247. <?
  248. if($AccessProjectName){
  249. echo " <font color='red' face='helvetica,arial,futura' size='3'>(Project: $AccessProjectName)</font>";
  250. }
  251. ?>
  252. </b>
  253. </font>
  254. </td>
  255. <td align="right">
  256. &nbsp;
  257. </td>
  258. </tr>
  259. <tr>
  260. <td colspan=2 height=1 bgcolor="black"><img src="./images/pixel.gif"></td>
  261. </tr>
  262. <tr>
  263. <td align="center" colspan=2 bgcolor=''><br>
  264. <?
  265. $tmp_str = '';
  266. $page_lable = urlencode("\"$searchThis\"". $tmp_str );
  267. ?> <DIV class="st1">
  268. <table width=100% border=0 cellspacing="1" cellpadding="2">
  269. <tr><td colspan=2 bgcolor="#9c9c9c" height=30 align=center>
  270. <font color="#FFFFFF"><b>Your search results for following criteria:</b></font>
  271. </td>
  272. </tr>
  273. <tr>
  274. <td width=200 bgcolor="#eeeeee"><b>Word</b>:</td><td bgcolor="#eeeeee"><?=$searchThis;?></td>
  275. </tr>
  276. </table>
  277. </DIV>
  278. <?=$msg_h;?>
  279. <br>
  280. <DIV class="st1">
  281. <table width=100% border=0 cellspacing="1" cellpadding="2">
  282. <tr bgcolor="#888888" align=center>
  283. <td bgcolor="#9c9c9c"><font color="#FFFFFF"><b>Record Type</b></font></td>
  284. <td bgcolor="#9c9c9c"><font color="#FFFFFF"><b>Match(es)</b></font></td>
  285. <td bgcolor="#9c9c9c"><font color="#FFFFFF"><b>Browse for Detail</b></font></td>
  286. </tr>
  287. <tr>
  288. <td width=200 bgcolor="#cccccc"> Bait:</td>
  289. <td width=200 align=center bgcolor="#eeeeee">
  290. <?
  291. //---- display bait -----------------
  292. $num = count($bait_selected_bait_arr);
  293. echo $num . "";
  294. ?>
  295. </td>
  296. <td align=center bgcolor="#eeeeee">
  297. <?
  298. if($num){
  299. $bait_selected_bait_str = implode(",", $bait_selected_bait_arr);
  300. echo "<input type=hidden name='bait_ids' id='bait_ids' value='$bait_selected_bait_str'>\n";
  301. echo "<a class=button href=\"javascript: browse_for_detail('bait.php', 'Search Bait for $page_lable', 'bait_ids', '', '');\">[Browse]</a>";
  302. }else{
  303. echo "&nbsp;";
  304. }
  305. ?>
  306. </td>
  307. </tr>
  308. <tr>
  309. <td bgcolor="#cccccc"> Hit (Report by Bait): </td>
  310. <td align=center bgcolor="#eeeeee">
  311. <?
  312. // -- display hits ----------------
  313. $num = count($hit_selected_bait_arr);
  314. echo $num . "";
  315. ?>
  316. </td>
  317. <td align=center bgcolor="#eeeeee">
  318. <?
  319. if($num){
  320. $hit_selected_bait_str = implode(",", $hit_selected_bait_arr);
  321. $hit_value_for_bait_str = '';
  322. foreach($hit_value_for_bait_arr as $key=>$value){
  323. $hit_value_for_bait_str .= $key . ",".$value . ":";
  324. }
  325. echo "<input type=hidden name='hit_ids_v' id='hit_ids_v' value='$hit_value_for_bait_str'>\n";
  326. echo "<input type=hidden name='hit_ids' id='hit_ids' value='$hit_selected_bait_str'>\n";
  327. echo "<a class=button href=\"javascript: browse_for_detail('bait.php', 'Search hits for $page_lable', 'hit_ids', 'hit_ids_v', '');\">[Browse]</a>";
  328. }else{
  329. echo "&nbsp;";
  330. }
  331. ?>
  332. </td>
  333. </tr>
  334. <tr>
  335. <td bgcolor="#cccccc"> Hit (Report by Sample): </td>
  336. <td align=center bgcolor="#eeeeee">
  337. <?
  338. // -- display hits ----------------
  339. $num = count($hit_selected_band_arr);
  340. echo $num . "";
  341. ?>
  342. </td>
  343. <td align=center bgcolor="#eeeeee">
  344. <?
  345. if($num){
  346. $hit_selected_band_str = implode(",", $hit_selected_band_arr);
  347. $hit_value_for_band_str = '';
  348. foreach($hit_value_for_band_arr as $key=>$value){
  349. $hit_value_for_band_str .= $key .",".$value . ":";
  350. }
  351. echo "<input type=hidden name='hit_Band_ids_v' id='hit_Band_ids_v' value='$hit_value_for_band_str'>\n";
  352. echo "<input type=hidden name='hit_Band_ids' id='hit_Band_ids' value='$hit_selected_band_str'>\n";
  353. echo "<a class=button href=\"javascript: browse_for_detail('band_show.php', 'Search hits for $page_lable', 'hit_Band_ids', 'hit_Band_ids_v','');\">[Browse]</a>";
  354. }else{
  355. echo "&nbsp;";
  356. }
  357. ?>
  358. </td>
  359. </tr>
  360. <tr>
  361. <td bgcolor="#cccccc"> TPP Hit (Report by Bait): </td>
  362. <td align=center bgcolor="#eeeeee">
  363. <?
  364. // -- display TPP hits ----------------
  365. $num = count($TPP_hit_selected_bait_arr);
  366. echo $num . "";
  367. ?>
  368. </td>
  369. <td align=center bgcolor="#eeeeee">
  370. <?
  371. if($num){
  372. $TPP_hit_selected_bait_str = implode(",", $TPP_hit_selected_bait_arr);
  373. $tpp_value_str = '';
  374. foreach($tpp_hit_value_for_bait_arr as $key=>$value){
  375. $tpp_value_str .= $key. ",".$value . ":";
  376. }
  377. echo "<input type=hidden name='hit_TPP_ids_v' id='hit_TPP_ids_v' value='$tpp_value_str'>\n";
  378. echo "<input type=hidden name='TPP_ids' id='TPP_ids' value='$TPP_hit_selected_bait_str'>\n";
  379. echo "<a class=button href=\"javascript: browse_for_detail('bait.php', 'Search TPP hits for $page_lable', 'TPP_ids', 'hit_TPP_ids_v', 'TPP');\">[Browse]</a>";
  380. }else{
  381. echo "&nbsp;";
  382. }
  383. ?>
  384. </td>
  385. </tr>
  386. <tr>
  387. <td bgcolor="#cccccc"> TPP Hit (Report by Sample): </td>
  388. <td align=center bgcolor="#eeeeee">
  389. <?
  390. // -- display TPP hits ----------------
  391. $num = count($TPP_hit_selected_band_arr);
  392. echo $num . "";
  393. ?>
  394. </td>
  395. <td align=center bgcolor="#eeeeee">
  396. <?
  397. if($num){
  398. $TPP_hit_selected_band_str = implode(",", $TPP_hit_selected_band_arr);
  399. $tpp_value_str = '';
  400. foreach($tpp_hit_value_for_band_arr as $key=>$value){
  401. $tpp_value_str .= $key. ",".$value . ":";
  402. }
  403. echo "<input type=hidden name='tpp_band_ids_v' id='tpp_band_ids_v' value='$tpp_value_str'>\n";
  404. echo "<input type=hidden name='tpp_band_ids' id='tpp_band_ids' value='$TPP_hit_selected_band_str'>\n";
  405. echo "<a class=button href=\"javascript: browse_for_detail('band_show.php', 'Search sample for $page_lable', 'tpp_band_ids', 'tpp_band_ids_v', 'TPP');\">[Browse]</a>";
  406. }else{
  407. echo "&nbsp;";
  408. }
  409. ?>
  410. </td>
  411. </tr>
  412. <tr>
  413. <td bgcolor="#cccccc"> Sample: </td>
  414. <td align=center bgcolor="#eeeeee">
  415. <?
  416. $num = count($band_selected_band_arr);
  417. echo $num . "";
  418. ?>
  419. </td>
  420. <td align=center bgcolor="#eeeeee">
  421. <?
  422. if($num){
  423. $band_selected_band_str = implode(",", $band_selected_band_arr);
  424. echo "<input type=hidden name='band_ids' id='band_ids' value='$band_selected_band_str'>\n";
  425. echo "<a class=button href=\"javascript: browse_for_detail('band_show.php', 'Search sample for $page_lable', 'band_ids', '','');\">[Browse]</a>";
  426. }else{
  427. echo "&nbsp;";
  428. }
  429. ?>
  430. </td>
  431. </tr>
  432. <tr>
  433. <?
  434. //---- display raw files ------------
  435. $num = 0;
  436. $total_imploded_str = '';
  437. $dis_arr = array();
  438. foreach($raw_file_searched_arr as $theTable => $theValue){
  439. if($theValue){
  440. $tmp_num = count($theValue);
  441. $num += $tmp_num;
  442. $the_imploded = $theTable . ":" . implode(",",$theValue);
  443. $total_imploded_str .= $the_imploded.";;";
  444. array_push($dis_arr, array("$theTable", $tmp_num, $theTable . ":" . implode(",",$theValue)));
  445. }
  446. }
  447. $num_tables = count($dis_arr);
  448. ?>
  449. <td rowspan="<?=$num_tables+1;?>" valign=top bgcolor="#cccccc"> Raw File / Folder: </td>
  450. <td align=center bgcolor="#eeeeee"><?="<font color='#FF0000'>total: $num</font>";?></td>
  451. <td align=center bgcolor="#eeeeee">
  452. <?
  453. if($num_tables){
  454. echo "<input type=hidden name='raw_ids' id='raw_ids' value='$total_imploded_str'>\n";
  455. echo "<a class=button href=\"javascript: browse_for_detail('../msManager/ms_storage_fetch_raw.php', 'Search raw file for $page_lable', 'raw_ids', '','');\">[Browse]</a>";
  456. }else{
  457. echo "&nbsp;";
  458. }
  459. ?>
  460. </td>
  461. </tr>
  462. <?
  463. $con= 0;
  464. foreach($dis_arr as $tmp_dis_arr){
  465. $con++;
  466. echo "<tr>
  467. <td align=center bgcolor=\"#eeeeee\">" . $tmp_dis_arr[0] . ": " . $tmp_dis_arr[1]. "</td>
  468. <td align=center bgcolor=\"#eeeeee\">\n";
  469. echo "<input type=hidden name='raw_ids$con' id='raw_ids$con' value='".$tmp_dis_arr[2]."'>\n";
  470. echo "<a class=button href=\"javascript: browse_for_detail('../msManager/ms_storage_fetch_raw.php', 'Search raw file for $page_lable', 'raw_ids$con', '','');\">[Browse]</a>";
  471. echo "</td>
  472. </tr>\n";
  473. }
  474. ?>
  475. </table>
  476. </div>
  477. </td>
  478. </tr>
  479. </table>
  480. </form>
  481. <?
  482. require("site_footer.php");
  483. //------------------------------------------------
  484. //return sql like str from fields and imploded str
  485. function get_like_str($field_arr, $search_tmp_str, $OrAnd=''){
  486. global $s_wildcard, $e_wildcard, $frm_search_OrAnd;
  487. $s_wildcard = '%';
  488. $e_wildcard = '%';
  489. $rt = '';
  490. if(!$OrAnd){
  491. $OrAnd = $frm_search_OrAnd;
  492. }else if($OrAnd == "="){
  493. $OrAnd = '';
  494. }
  495. foreach($field_arr as $field){
  496. $tmp_str = '';
  497. if($rt) $rt .= " OR ";
  498. if($OrAnd){
  499. $tmp_str = "`".$field."`" . " LIKE '".$s_wildcard;
  500. $tmp_str .= str_replace(" ", $e_wildcard . "' ".$OrAnd." `".$field."` LIKE '".$s_wildcard, $search_tmp_str).$e_wildcard."'";
  501. if($OrAnd == 'AND'){
  502. $tmp_str = "($tmp_str)";
  503. }
  504. $rt .= $tmp_str;
  505. }else{
  506. $search_tmp_str = str_replace("@@", " ", $search_tmp_str);
  507. $rt .= "`".$field."`" . "='".$search_tmp_str."'";
  508. }
  509. }
  510. return $rt;
  511. }
  512. ?>