Changeset 2424 for trunk/include/category_cats.inc.php
- Timestamp:
- Jul 6, 2008, 12:13:28 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/category_cats.inc.php
r2330 r2424 89 89 else if ($conf['allow_random_representative']) 90 90 {// searching a random representant among elements in sub-categories 91 $query = ' 91 if ($row['count_images']>0) 92 { 93 $query = ' 92 94 SELECT image_id 93 95 FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic 94 96 ON ic.category_id = c.id'; 95 $query.= '97 $query.= ' 96 98 WHERE (c.id='.$row['id'].' OR uppercats LIKE \''.$row['uppercats'].',%\')' 97 .get_sql_condition_FandF98 (99 array100 (101 'forbidden_categories' => 'c.id',102 'visible_categories' => 'c.id',103 'visible_images' => 'image_id'104 ),105 "\n AND"106 ).'99 .get_sql_condition_FandF 100 ( 101 array 102 ( 103 'forbidden_categories' => 'c.id', 104 'visible_categories' => 'c.id', 105 'visible_images' => 'image_id' 106 ), 107 "\n AND" 108 ).' 107 109 ORDER BY RAND() 108 110 LIMIT 0,1 109 111 ;'; 110 $subresult = pwg_query($query); 111 if (mysql_num_rows($subresult) > 0) 112 { 113 list($image_id) = mysql_fetch_row($subresult); 112 $subresult = pwg_query($query); 113 if (mysql_num_rows($subresult) > 0) 114 { 115 list($image_id) = mysql_fetch_row($subresult); 116 } 114 117 } 115 118 } 116 119 else 117 120 { // searching a random representant among representant of sub-categories 118 $query = ' 119 SELECT representative_picture_id 120 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' 121 ON id = cat_id and user_id = '.$user['id'].' 122 WHERE uppercats LIKE \''.$row['uppercats'].',%\' 123 AND representative_picture_id IS NOT NULL' 124 .get_sql_condition_FandF 125 ( 126 array 127 ( 128 'visible_categories' => 'id', 129 ), 130 "\n AND" 131 ).' 132 ORDER BY RAND() 133 LIMIT 0,1 134 ;'; 135 $subresult = pwg_query($query); 136 if (mysql_num_rows($subresult) > 0) 137 { 138 list($image_id) = mysql_fetch_row($subresult); 121 if ($row['count_categories']>0 and $row['count_images']>0) 122 { 123 $query = ' 124 SELECT representative_picture_id 125 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' 126 ON id = cat_id and user_id = '.$user['id'].' 127 WHERE uppercats LIKE \''.$row['uppercats'].',%\' 128 AND representative_picture_id IS NOT NULL' 129 .get_sql_condition_FandF 130 ( 131 array 132 ( 133 'visible_categories' => 'id', 134 ), 135 "\n AND" 136 ).' 137 ORDER BY RAND() 138 LIMIT 0,1 139 ;'; 140 $subresult = pwg_query($query); 141 if (mysql_num_rows($subresult) > 0) 142 { 143 list($image_id) = mysql_fetch_row($subresult); 144 } 139 145 } 140 146 }
Note: See TracChangeset
for help on using the changeset viewer.