{"id":232851,"date":"2023-01-30T10:17:00","date_gmt":"2023-01-30T07:17:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=232851"},"modified":"2023-02-06T11:43:46","modified_gmt":"2023-02-06T08:43:46","slug":"kuidas-printida-mysql-i-tabeli-kokkuvotet-php-abil","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/et\/kuidas-printida-mysql-i-tabeli-kokkuvotet-php-abil\/","title":{"rendered":"Kuidas printida MySQL-i tabeli kokkuv\u00f5tet PHP abil?"},"content":{"rendered":"<p><a href=\"https:\/\/helloacm.com\/how-to-generate-100k-test-data-to-mysql-database\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">MySQL<\/a> -i tabelis on k\u00e4sk <strong>N\u00e4ita tabeli olekut<\/strong>, mis prindib tabeli kokkuv\u00f5tte, kuid see sisaldab palju teavet k\u00f5igi praeguse andmebaasi tabelite kohta (andmebaasi muutmiseks kasutage &#8216;kasuta andmebaasi_nimi&#8217;), mis pole nii kasutajas\u00f5bralik.<\/p>\n<p>Mida me tahame teada, on andmete ja indeksi suurus. Sellise teabe printimiseks v\u00f5ite kasutada j\u00e4rgmist <a href=\"https:\/\/helloacm.com\/the-php-bing-wallpaper-bot-crawler\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">PHP -skripti.<\/a><\/p>\n<pre><code>&lt;?php\n\u00a0 require('conn.php'); \/\/ connect your database using e.g. $connection = mysqli_connect(...)\n\u00a0 $query = \"show table status\";\n\u00a0 $result = mysqli_query($connection, $query);\n\u00a0 $ds = 0;\n\u00a0 $is = 0;\n\u00a0 echo \"&lt;table style='text-align:left;width:100%'&gt;\";\n\u00a0 echo \"&lt;tr \u00a0style='background:blue;color:yellow;'&gt;&lt;th&gt;Name&lt;\/th&gt;&lt;th&gt;Data&lt;\/th&gt;&lt;th&gt;Index&lt;\/th&gt;&lt;\/tr&gt;\";\n\u00a0 function format($c) {\n\u00a0 \u00a0 return (round($c \/ 1024, 2)). 'KB';\n\u00a0 }\n\u00a0 while ($row = mysqli_fetch_assoc($result)) {\n\u00a0 \u00a0 echo \"&lt;tr&gt;&lt;th&gt;\". ($row['Name']). '&lt;\/th&gt;';\n\u00a0 \u00a0 echo \"&lt;th&gt;\". format($row['Data_length']). \"&lt;\/th&gt;\";\n\u00a0 \u00a0 echo \"&lt;th&gt;\". format($row['Index_length']). \"&lt;\/th&gt;\";\n\u00a0 \u00a0 $ds += $row['Data_length'];\n\u00a0 \u00a0 $is += $row['Index_length'];\n\u00a0 \u00a0 echo \"&lt;\/tr&gt;\";\n\u00a0 }\n\u00a0 echo \"&lt;tr style='background:lightblue;'&gt;\";\n\u00a0 echo \"&lt;th&gt;\". format($ds + $is). \"&lt;\/th&gt;&lt;th&gt;\". format($ds). \"&lt;\/th&gt;&lt;th&gt;\". format($is). \"&lt;\/th&gt;\";\n\u00a0 echo \"&lt;\/tr&gt;&lt;\/table&gt;\";<\/code><\/pre>\n<p>Siin on n\u00e4ide tavalisest <a href=\"https:\/\/wordpress.mediadoma.com\/et\/kuidas-lisada-disqusi-kui-kommentaarid-on-wordpressis-suletud\/\" title=\"Wordpressi\">WordPressi<\/a> andmebaasist. Vormindame suuruse kasutades KB. Nii saaks aeg-ajalt j\u00e4lgida tabeli kasutamist. Samuti saate v\u00e4ljundi vormindamiseks muuta \u00fclaltoodud koodi stiilset CSS-i.<\/p>\n<p>mysql-show-table-status-in-php-example<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kuidas printida MySQL-i tabeli kokkuv\u00f5tet PHP abil?<\/p>\n","protected":false},"author":1,"featured_media":224526,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[718,894,916,802],"tags":[1165],"class_list":["post-232851","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arendaja","category-kood","category-muud","category-php-4","tag-affiai-et"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/posts\/232851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/comments?post=232851"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/posts\/232851\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/media\/224526"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/media?parent=232851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/categories?post=232851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/et\/wp-json\/wp\/v2\/tags?post=232851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}