cvs: pearweb /include pear-database-category.php

[email protected] ("Helgi ?ormar ?orbj?rnsson")
Newsgroups php.pear.cvs,php.pear.core
Message-ID <cvsdufuz1209777404@cvsserver>
dufuz		Sat May  3 01:16:44 2008 UTC

  Modified files:              
    /pearweb/include	pear-database-category.php 
  Log:
  Cosmetics and use SITE instead of hardcoding pear
  
http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database-category.php?r1=1.7&r2=1.8&diff_format=u
Index: pearweb/include/pear-database-category.php
diff -u pearweb/include/pear-database-category.php:1.7 pearweb/include/pear-database-category.php:1.8
--- pearweb/include/pear-database-category.php:1.7	Sat Mar  8 23:03:16 2008
+++ pearweb/include/pear-database-category.php	Sat May  3 01:16:44 2008
@@ -18,7 +18,7 @@
    |           Martin Jansen <[email protected]>                                 |
    |           Richard Heyes <[email protected]>                            |
    +----------------------------------------------------------------------+
-   $Id: pear-database-category.php,v 1.7 2008/03/08 23:03:16 dufuz Exp $
+   $Id: pear-database-category.php,v 1.8 2008/05/03 01:16:44 dufuz Exp $
 */
 
 // These classes correspond to tables and methods define operations on
@@ -183,20 +183,25 @@
         global $dbh;
         $recent = array();
 
-        $query = "SELECT p.id AS id, " .
-            "p.name AS name, " .
-            "p.summary AS summary, " .
-            "r.version AS version, " .
-            "r.releasedate AS releasedate, " .
-            "r.releasenotes AS releasenotes, " .
-            "r.doneby AS doneby, " .
-            "r.state AS state " .
-            "FROM packages p, releases r, categories c " .
-            "WHERE p.package_type = 'pear' AND p.id = r.package " .
-            "AND p.category = c.id AND c.name = '" . $category . "'" .
-            "ORDER BY r.releasedate DESC";
+        $query = '
+            SELECT
+                p.id AS id,
+                p.name AS name,
+                p.summary AS summary,
+                r.version AS version,
+                r.releasedate AS releasedate,
+                r.releasenotes AS releasenotes,
+                r.doneby AS doneby,
+                r.state AS state
+            FROM packages p, releases r, categories c
+            WHERE
+                p.package_type = ?
+                AND p.id = r.package
+                AND p.category = c.id
+                AND c.name = ?
+            ORDER BY r.releasedate DESC';
 
-        $sth = $dbh->limitQuery($query, 0, $n);
+        $sth = $dbh->limitQuery($query, 0, $n, array(SITE, $category));
         while ($sth->fetchInto($row, DB_FETCHMODE_ASSOC)) {
             $recent[] = $row;
         }
@@ -213,8 +218,8 @@
     static function isValid($category)
     {
         global $dbh;
-        $query = "SELECT id FROM categories WHERE name = ?";
-        $sth = $dbh->query($query, array($category));
+        $sql = 'SELECT id FROM categories WHERE name = ?';
+        $sth = $dbh->query($sql, array($category));
         return ($sth->numRows() > 0);
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.