Fwd: Re: [dev] Category - getCategoriesByAttributes

Chuck Hagenbuch chuck at horde.org
Mon Nov 3 08:30:31 PST 2003



----- Forwarded message from mikael at nufort.net -----
    Date: Mon, 03 Nov 2003 17:30:24 +0100
    From: Mikael Geijer <mikael at nufort.net>
Reply-To: Mikael Geijer <mikael at nufort.net>
 Subject: Re: [dev] Category - getCategoriesByAttributes
      To: Chuck Hagenbuch <chuck at horde.org>

OK here's the diff:

Chuck Hagenbuch wrote:

>Quoting Mikael Geijer <mikael at nufort.net>:
>
>
>
>>Will also match a modify action within the given timestamps (if there is
>>one..).
>>
>>
>
>Ah, okay, I understand, I think... However:
>
>
>
>This diff looks like it was generated backwards? Also hard to tell what you're
>changing. Can you re-send a diff -u with a bit more context?
>
>
>
diff -u sql.php.bak sql.php
--- sql.php.bak 2003-10-30 19:47:20.000000000 +0100
+++ sql.php     2003-10-30 19:46:34.000000000 +0100
@@ -700,16 +700,19 @@
         $joins = array();
         for ($i = 1; $i <= $this->_tableCount; $i++) {
             $joins[] = 'LEFT JOIN ' .
$this->_params['table_attributes'] . ' a' . $i . ' ON a' . $i .
'.category_id = c.category_id';
+           $attnames[] = 'AND a1.attribute_name = a' . $i .
'.attribute_name';
         }
         $joins = implode(' ', $joins);
+       $attnames = implode(' ',$attnames);

         $query = sprintf('SELECT DISTINCT a1.category_id,
c.category_name FROM %s c %s' .
-                         ' WHERE c.group_uid = %s AND %s%s',
+                         ' WHERE c.group_uid = %s AND %s%s %s',
                          $this->_params['table'],
                          $joins,
                          $this->_db->quote($this->_params['group']),
                          $query,
-                         $levelQuery);
+                         $levelQuery,
+                        $attnames);

         Horde::logMessage('SQL Query by
Category_sql::getCategoriesByAttributes(): ' . $query, __FILE__,
__LINE__, PEAR_LOG_DEBUG);

/Mikael

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=- Mikael Geijer, nufort HB (nufort.net), Oebb AB (oebb.net)
=- mobile: +46 70 7455239 office +46 70 7455239
=- email:  mikael at nufort.net
=- snail:  Kyrklunden 8, 122 32 Enskede, Sweden
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=



----- End forwarded message -----


-chuck

--
Charles Hagenbuch, <chuck at horde.org>
Born right the first time.
-------------- next part --------------
--- sql.php.bak	2003-10-30 19:47:20.000000000 +0100
+++ sql.php	2003-10-30 19:46:34.000000000 +0100
@@ -700,16 +700,19 @@
         $joins = array();
         for ($i = 1; $i <= $this->_tableCount; $i++) {
             $joins[] = 'LEFT JOIN ' . $this->_params['table_attributes'] . ' a' . $i . ' ON a' . $i . '.category_id = c.category_id';
+	    $attnames[] = 'AND a1.attribute_name = a' . $i . '.attribute_name';
         }
         $joins = implode(' ', $joins);
+	$attnames = implode(' ',$attnames);
 
         $query = sprintf('SELECT DISTINCT a1.category_id, c.category_name FROM %s c %s' .
-                         ' WHERE c.group_uid = %s AND %s%s',
+                         ' WHERE c.group_uid = %s AND %s%s %s',
                          $this->_params['table'],
                          $joins,
                          $this->_db->quote($this->_params['group']),
                          $query,
-                         $levelQuery);
+                         $levelQuery,
+			 $attnames);
 
         Horde::logMessage('SQL Query by Category_sql::getCategoriesByAttributes(): ' . $query, __FILE__, __LINE__, PEAR_LOG_DEBUG);
 


More information about the dev mailing list