cvs: pearweb /public_html package-search.php

From: Date: Wed, 22 May 2002 20:47:20 +0000
Subject: cvs: pearweb /public_html package-search.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4042@lists.php.net to get a copy of this message
mj Wed May 22 16:47:20 2002 EDT Modified files: /pearweb/public_html package-search.php Log: * Use uppercase MySQL keywords * Don't print maintainer handle along with the package name. # This does not make much sense and has no special purpose. Index: pearweb/public_html/package-search.php diff -u pearweb/public_html/package-search.php:1.11 pearweb/public_html/package-search.php:1.12 --- pearweb/public_html/package-search.php:1.11 Wed May 22 10:38:43 2002 +++ pearweb/public_html/package-search.php Wed May 22 16:47:20 2002 @@ -3,14 +3,10 @@ $form = new HTML_Form($_SERVER['PHP_SELF']); -/* -* TODO -* - More stuff to search on, eg summary, version -*/ - -/*************************************** -** Header -***************************************/ +/** + * TODO + * - More stuff to search on, eg summary, version + */ response_header("Package search"); echo '<h1>Package search</h1>'; @@ -68,7 +64,7 @@ ***************************************/ if(!empty($_GET)) { - $dbh->setErrorHandling(PEAR_ERROR_DIE); + // $dbh->setErrorHandling(PEAR_ERROR_DIE); $dbh->setFetchmode(DB_FETCHMODE_ASSOC); $where = array(); $bool = @$_GET['bool'] == 'AND' ? ' AND ' : ' OR '; @@ -77,14 +73,14 @@ if(!empty($_GET['pkg_name'])) { $searchwords = preg_split('/\s+/', $_GET['pkg_name']); for($i=0; $i<count($searchwords); $i++) { - $searchwords[$i] = "name like '%".addslashes($searchwords[$i])."%'"; + $searchwords[$i] = "name LIKE '%".addslashes($searchwords[$i])."%'"; } $where[] = '('.implode($bool, $searchwords).')'; } // Build maintainer part of query if(!empty($_GET['pkg_maintainer'])) { - $where[] = "handle like '%".addslashes($_GET['pkg_maintainer'])."%'"; + $where[] = "handle LIKE '%".addslashes($_GET['pkg_maintainer'])."%'"; } // Build category part of query @@ -93,8 +89,8 @@ } // Compose query and execute - $where = !empty($where) ? ' AND '.implode(' AND ', $where) : ''; - $sql = "select p.id, p.name, p.category, p.summary, m.handle from packages p, maintains m where p.id = m.package " . $where . " group by p.id order by p.name"; + $where = !empty($where) ? 'AND '.implode(' AND ', $where) : ''; + $sql = "SELECT p.id, p.name, p.category, p.summary FROM packages p, maintains m WHERE p.id = m.package " . $where . " GROUP BY p.id ORDER BY p.name"; $result = $dbh->query($sql); // Print any results @@ -121,7 +117,7 @@ $bb = new Borderbox($title_html); while ($result->fetchInto($row, DB_FETCHMODE_ASSOC, $rownum++) AND $rownum <= $to) { - echo ' <dt><a href="package-info.php?pacid='.$row['id'].'">'.$row['name'].'</a> (<a href="/account-info.php?handle='.$row['handle'].'">'.$row['handle'].'</a>)</dt>'; + echo ' <dt><a href="package-info.php?pacid='.$row['id'].'">'.$row['name'].'</a></dt>'; echo ' <dd>'.$row['summary'].'</dd>'; echo ' <br /><br />'; }

« previous php.pear.cvs (#4042) next »