  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: reviews.php 210 2005-10-04 05:47:42Z hpdl $ |
| |
| 3 | + | $Id: reviews.php 212 2005-10-04 07:55:32Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
101 | 101 | | return $Qcheck->valueInt('total'); |
| |
102 | 102 | | } |
| |
103 | 103 | | |
  |
104 | | - | function exists($id) { |
| |
| 104 | + | function exists($id = null) { |
|
105 | 105 | | global $osC_Database; |
| |
106 | 106 | | |
  |
107 | | - | $Qcheck = $osC_Database->query('select reviews_id from :table_reviews where products_id = :products_id and languages_id = :languages_id and reviews_status = 1 limit 1'); |
| |
| 107 | + | $Qcheck = $osC_Database->query('select reviews_id from :table_reviews where'); |
| |
| 108 | + | |
| |
| 109 | + | if (is_numeric($id)) { |
| |
| 110 | + | $Qcheck->appendQuery('products_id = :products_id and'); |
| |
| 111 | + | $Qcheck->bindInt(':products_id', $id); |
| |
| 112 | + | } |
| |
| 113 | + | |
| |
| 114 | + | $Qcheck->appendQuery('languages_id = :languages_id and reviews_status = 1 limit 1'); |
|
108 | 115 | | $Qcheck->bindTable(':table_reviews', TABLE_REVIEWS); |
  |
109 | | - | $Qcheck->bindInt(':products_id', $id); |
|
110 | 116 | | $Qcheck->bindInt(':languages_id', $_SESSION['languages_id']); |
| |
111 | 117 | | $Qcheck->execute(); |
| |
112 | 118 | | |
| |
|
|
 |
… |
|
116 | 122 | | |
| |
117 | 123 | | return false; |
| |
118 | 124 | | } |
  |
| 125 | + | |
| |
| 126 | + | function &getListing($id = null) { |
| |
| 127 | + | global $osC_Database; |
| |
| 128 | + | |
| |
| 129 | + | $Qreviews = $osC_Database->query('select r.reviews_id, left(r.reviews_text, 100) as reviews_text, r.reviews_rating, r.date_added, p.products_id, pd.products_name, p.products_image, r.customers_name from :table_reviews r, :table_products p, :table_products_description pd where r.reviews_status = 1 and r.products_id = p.products_id and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id and r.languages_id = :languages_id order by r.reviews_id desc'); |
| |
| 130 | + | $Qreviews->bindTable(':table_reviews', TABLE_REVIEWS); |
| |
| 131 | + | $Qreviews->bindTable(':table_products', TABLE_PRODUCTS); |
| |
| 132 | + | $Qreviews->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); |
| |
| 133 | + | $Qreviews->bindInt(':language_id', $_SESSION['languages_id']); |
| |
| 134 | + | $Qreviews->bindInt(':languages_id', $_SESSION['languages_id']); |
| |
| 135 | + | $Qreviews->setBatchLimit((isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1), MAX_DISPLAY_NEW_REVIEWS); |
| |
| 136 | + | $Qreviews->execute(); |
| |
| 137 | + | |
| |
| 138 | + | return $Qreviews; |
| |
| 139 | + | } |
  |
119 | 140 | | } |
| |
120 | 141 | | ?> |