PHP PDO retrieve MYSQL DB Size

后端 未结 1 1304
花落未央
花落未央 2021-01-26 12:13

Trying to convert my ugly mysql_ into PDO but I\'m having difficulty creating the equivalent.

$rows = mysql_query(\"SHOW TABLE STATUS\"); 
$dbSize = 0; 
while ($         


        
相关标签:
1条回答
  • 2021-01-26 12:48

    Older versions of PHP does not allow dereferencing returned arrays. See example 7 on this page. To fix, try this:

    $sth = $conn->query('SHOW TABLE STATUS');
    $dbSize = 0;
    $row = $sth->fetch(PDO::FETCH_ASSOC);
    $dbSize = $row["Data_length"];
    $decimals = 2;  
    $mbytes = round($dbSize/(1024*1024),$decimals);
    echo "$dbSize";
    
    0 讨论(0)
提交回复
热议问题