Pārlūkot izejas kodu

Problematic MySQL reserved keyword

`read` and `reads` are reserved keywords
Alexandre Alapetite 9 gadi atpakaļ
vecāks
revīzija
bee833bf52

+ 3 - 3
app/Models/StatsDAO.php

@@ -38,9 +38,9 @@ class FreshRSS_StatsDAO extends Minz_ModelPdo {
 		}
 		$sql = <<<SQL
 SELECT COUNT(1) AS total,
-COUNT(1) - SUM(e.is_read) AS unread,
-SUM(e.is_read) AS read,
-SUM(e.is_favorite) AS favorite
+COUNT(1) - SUM(e.is_read) AS count_unreads,
+SUM(e.is_read) AS count_reads,
+SUM(e.is_favorite) AS count_favorites
 FROM {$this->prefix}entry AS e
 , {$this->prefix}feed AS f
 WHERE e.id_feed = f.id

+ 6 - 6
app/views/stats/index.phtml

@@ -23,18 +23,18 @@
 				</tr>
 				<tr>
 					<th><?php echo _t('admin.stats.status_read'); ?></th>
-					<td class="numeric"><?php echo format_number($this->repartition['main_stream']['read']); ?></td>
-					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['read']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['main_stream']['count_reads']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['count_reads']); ?></td>
 				</tr>
 				<tr>
 					<th><?php echo _t('admin.stats.status_unread'); ?></th>
-					<td class="numeric"><?php echo format_number($this->repartition['main_stream']['unread']); ?></td>
-					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['unread']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['main_stream']['count_unreads']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['count_unreads']); ?></td>
 				</tr>
 				<tr>
 					<th><?php echo _t('admin.stats.status_favorites'); ?></th>
-					<td class="numeric"><?php echo format_number($this->repartition['main_stream']['favorite']); ?></td>
-					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['favorite']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['main_stream']['count_favorites']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['count_favorites']); ?></td>
 				</tr>
 			</tbody>
 		</table>

+ 4 - 4
app/views/stats/repartition.phtml

@@ -12,7 +12,7 @@
 		if (!empty($feeds)) {
 			echo '<optgroup label="', $category->name(), '">';
 			foreach ($feeds as $feed) {
-				if ($this->feed && $feed->id() == $this->feed->id()){
+				if ($this->feed && $feed->id() == $this->feed->id()) {
 					echo '<option value="', $feed->id(), '" selected="selected" data-url="', _url('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
 				} else {
 					echo '<option value="', $feed->id(), '" data-url="', _url('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
@@ -39,9 +39,9 @@
 		</tr>
 		<tr>
 			<td class="numeric"><?php echo $this->repartition['total']; ?></td>
-			<td class="numeric"><?php echo $this->repartition['read']; ?></td>
-			<td class="numeric"><?php echo $this->repartition['unread']; ?></td>
-			<td class="numeric"><?php echo $this->repartition['favorite']; ?></td>
+			<td class="numeric"><?php echo $this->repartition['count_reads']; ?></td>
+			<td class="numeric"><?php echo $this->repartition['count_unreads']; ?></td>
+			<td class="numeric"><?php echo $this->repartition['count_favorites']; ?></td>
 		</tr>
 		</table>
 	</div>