Welcome, Guest
  • Author Topic: getting the satabase space  (Read 2206 times)

    Andresss

    • Systems Administrator
    • *****
    • Posts: 738
    • check me out at www.asb-labs.com/blog
      • View Profile
      • asb-labs
      • Email
    getting the satabase space
    « on: 10/08/05, 03:10 »
    hi guys, does anybody know how to get a database space and a certain table in it?
    halemos de flash en espaņol!....wondering about crazy flash experiments?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: getting the satabase space
    « Reply #1 on: 10/10/05, 03:41 »
    Which language, which database.

    Jorge

    Andresss

    • Systems Administrator
    • *****
    • Posts: 738
    • check me out at www.asb-labs.com/blog
      • View Profile
      • asb-labs
      • Email
    Re: getting the satabase space
    « Reply #2 on: 10/10/05, 08:59 »
    mysql with php...
    halemos de flash en espaņol!....wondering about crazy flash experiments?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: getting the satabase space
    « Reply #3 on: 10/10/05, 09:40 »
    You can list tables on a database: http://es2.php.net/manual/en/function.mysql-list-tables.php. Check also on left side all the functions available in mysql API

    Jorge

    Andresss

    • Systems Administrator
    • *****
    • Posts: 738
    • check me out at www.asb-labs.com/blog
      • View Profile
      • asb-labs
      • Email
    Re: getting the satabase space
    « Reply #4 on: 10/10/05, 15:41 »
    i mean the space that the database is using expressed in bytes and the space that a table is unsing expressed in bytes as well...
    halemos de flash en espaņol!....wondering about crazy flash experiments?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: getting the satabase space
    « Reply #5 on: 10/10/05, 17:00 »
    Quote
    Check also on left side all the functions available in mysql API

    Can you see it there?

    Jorge

    Andresss

    • Systems Administrator
    • *****
    • Posts: 738
    • check me out at www.asb-labs.com/blog
      • View Profile
      • asb-labs
      • Email
    Re: getting the satabase space
    « Reply #6 on: 10/10/05, 21:49 »
    sorry.. yep it was there.. here is what i found:

    function mydbsize($filesize){
    $bytes = array('KB', 'KB', 'MB', 'GB', 'TB'); # values are always displayed
            if ($filesize < 1024) $filesize = 1; # in at least kilobytes.
            for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;
            $file_size_info['size'] = ceil($filesize);
            $file_size_info['type'] = $bytes[$i];
            return $file_size_info;
    }

    mysql_select_db ($this->dbname);
                             $rows = mysql_query("SHOW TABLE STATUS");
                             $dbsize = 0;
                             while ($row = mysql_fetch_array($rows)) {
                             $dbsize += $row['Data_length'] + $row['Index_length'];
                             }
    mydbsize($dbsize);

    i would like to add it to an amfphp function... is ti possible?.. my first tests are not very good...
    halemos de flash en espaņol!....wondering about crazy flash experiments?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: getting the satabase space
    « Reply #7 on: 10/11/05, 02:27 »
    Anything that you can do with PHP can be done in amfphp.

    Jorge

    Andresss

    • Systems Administrator
    • *****
    • Posts: 738
    • check me out at www.asb-labs.com/blog
      • View Profile
      • asb-labs
      • Email
    Re: getting the database space
    « Reply #8 on: 10/12/05, 00:57 »
    hey hi guys i have this problem... i want to return my db space but i dont know how to do it, this is my code:

    Code: [Select]
         function chSett(){
              function file_size_info($filesize) {
            $bytes = array('KB', 'KB', 'MB', 'GB', 'TB'); # values are always displayed
            if ($filesize < 1024) $filesize = 1; # in at least kilobytes.
            for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;
            $file_size_info['size'] = ceil($filesize);
            $file_size_info['type'] = $bytes[$i];
            return $file_size_info;
            }
            $rows = mysql_query("SHOW TABLE STATUS");
                    $dbsize = 0;
                  while ($row = mysql_fetch_array($rows)) {
                  $dbsize += $row['Data_length'] + $row['Index_length'];
                  }
            $dbsize = file_size_info($dbsize);
            $andy="el mejor";
            $myquery= mysql_query("select ttpp.tPeriods, enesettings.tPeriod, enesettings.tempo, enesettings.tempow, enesettings.disponible from enesettings join ttpp");
            return "$myquery {$dbsize['size']} {$dbsize['type']}";

          }

    but it outputs something like:  Result: "Resource id #20 52 KB"
    halemos de flash en espaņol!....wondering about crazy flash experiments?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: getting the satabase space
    « Reply #9 on: 10/12/05, 03:25 »
    Your return:

    return "$myquery {$dbsize['size']} {$dbsize['type']}";

    The output:

     Result: "Resource id #20 52 KB"

    Only the size?

    return "$myquery {$dbsize['size']}";

    Jorge

    Andresss

    • Systems Administrator
    • *****
    • Posts: 738
    • check me out at www.asb-labs.com/blog
      • View Profile
      • asb-labs
      • Email
    Re: getting the satabase space
    « Reply #10 on: 10/12/05, 08:42 »
    well i wanted to output a query too, thats why i put that query there... do u think it would be better if i call them separate of each other?
    halemos de flash en espaņol!....wondering about crazy flash experiments?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: getting the satabase space
    « Reply #11 on: 10/12/05, 08:56 »
    Quote
    output a query too

    Don't understand

    Jorge

    Andresss

    • Systems Administrator
    • *****
    • Posts: 738
    • check me out at www.asb-labs.com/blog
      • View Profile
      • asb-labs
      • Email
    Re: getting the satabase space
    « Reply #12 on: 10/12/05, 09:01 »
    $myquery= mysql_query("select ttpp.tPeriods, enesettings.tPeriod, enesettings.tempo, enesettings.tempow, enesettings.disponible from enesettings join ttpp");    <-------- the query

    return "$myquery {$dbsize['size']} {$dbsize['type']}";
                   |
                   |
                the quey is return with the space, i think dats why it outputs: Resource id #20 52 KB"
    halemos de flash en espaņol!....wondering about crazy flash experiments?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: getting the satabase space
    « Reply #13 on: 10/12/05, 09:52 »
    If you want to return the result of your query, use:

    return $myquery

    If you don't know how to walk a remoting Recordset object, check http://www.flash-db.com/Tutorials/loading/loadingData.php?page=6

    Jorge