Changeset 521388
- Timestamp:
- 03/20/2012 05:04:35 PM (14 years ago)
- File:
-
- 1 edited
-
database-peek/trunk/statistics.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
database-peek/trunk/statistics.php
r521032 r521388 17 17 global $wpdb; 18 18 19 $tabletotal = $wpdb->get_var( "select count(*) from $table" ); 19 20 $rows = $wpdb->get_results( "select * from $table where 1 = 0" ); 20 21 $col_names = $wpdb->get_col_info('name'); … … 45 46 </tbody> 46 47 </table> 48 <br> 47 49 <?php 48 50 } 49 51 50 52 51 echo "<h4>Distinct values</h4>"; 53 echo "<strong>Distinct values:</strong> "; 54 $res = $wpdb->get_var( "select count(distinct $n) from $table" ); 55 $percent = round(100 * $res / $tabletotal, 2); 56 echo "$res ($percent%)<br>"; 52 57 53 58 54 echo "<h4>Average length</h4>"; 59 echo "<strong>Average:</strong> "; 60 $res = $wpdb->get_var( "select avg($n) from $table" ); 61 $res = round($res, 2); 62 echo "$res<br>"; 55 63 56 64 57 echo "<h4>Nulls</h4>"; 65 echo "<strong>Total:</strong> "; 66 $res = $wpdb->get_var( "select sum($n) from $table" ); 67 $res = round($res, 2); 68 echo "$res<br>"; 69 70 71 echo "<strong>Average length:</strong> "; 72 $res = $wpdb->get_var( "select avg(length($n)) from $table" ); 73 $res = round($res, 2); 74 echo "$res<br>"; 75 76 77 echo "<strong>Nulls:</strong> "; 78 $res = $wpdb->get_var( "select count(*) from $table where $n is null" ); 79 $percent = round(100 * $res / $tabletotal, 2); 80 echo "$res ($percent%)<br>"; 81 82 83 echo "<strong>Empty:</strong> "; 84 $res = $wpdb->get_var( "select count(*) from $table where $n = ''" ); 85 $percent = round(100 * $res / $tabletotal, 2); 86 echo "$res ($percent%)<br>"; 58 87 59 88
Note: See TracChangeset
for help on using the changeset viewer.