示例#1
0
function get_count_from_db()
{
    $result = _mysql_query("select count(*) from result");
    if (!$result) {
        return false;
    }
    $count = _mysql_fetch_array($result);
    _mysql_free_result($result);
    return $count[0];
}
示例#2
0
function showTableStatus($db)
{
    $size = 0;
    $out = "";
    start_table();
    row1($db, 15);
    row_array(array("Name", "Engine", "Version", "Row Format", "Rows", "Avg Row Length (KB)", "Data Length (MB)", "Max Data Length (MB)", "Index Length (MB)", "Data free (MB)", "Create Time", "Update Time", "Check Time", "Create Options", "Comment"));
    _mysql_select_db($db);
    $result = _mysql_query("show table status");
    while ($row = _mysql_fetch_array($result)) {
        $size += $row["Data_length"] + $row["Index_length"];
        $engine = $row["Engine"];
        if (!$engine) {
            $engine = $row["Type"];
        }
        row_array(array($row["Name"], $engine, $row["Version"], $row["Row_format"], $row["Rows"], round($row["Avg_row_length"] / 1024, 2), round($row["Data_length"] / (1024 * 1024), 2), round($row["Max_data_length"] / (1024 * 1024), 2), round($row["Index_length"] / (1024 * 1024), 2), round($row["Data_free"] / (1024 * 1024), 2), $row["Create_time"], $row["Update_time"], $row["Check_time"], $row["Create_options"], $row["Comment"]));
    }
    $size = round($size / 1024 / 1024, 1);
    row2("Total Table Sizes (MB)", $size);
    end_table();
    echo "<BR><BR>";
}
示例#3
0
function cherokee_mysql_fetch_array(&$result, $result_type = MYSQL_BOTH)
{
    if (!_is_result($result)) {
        return _mysql_fetch_array(&$result, $result_type);
    }
    // No RESULT field present
    if ($result["_dbslayer"]["_idxres"] < 0) {
        return FALSE;
    }
    $idx = $result["_dbslayer"]["_idxres"];
    $tmp =& $result[$idx];
    // reset internal index
    if ($result["_dbslayer"]["_idxrow"] >= $result["_dbslayer"]["_rows"]) {
        $result["_dbslayer"]["_last_access"] = -1;
        $result["_dbslayer"]["_idxrow"] = 0;
        return FALSE;
    }
    $idx = $result["_dbslayer"]["_idxrow"];
    $result["_dbslayer"]["_last_access"] = $result["_dbslayer"]["_idxrow"];
    $result["_dbslayer"]["_idxrow"]++;
    $num = $tmp["RESULT"]["ROWS"][$idx];
    if ($result_type == MYSQL_NUM) {
        return $num;
    }
    $keys = $tmp["RESULT"]["HEADER"];
    $vals = $tmp["RESULT"]["ROWS"][$idx];
    $assoc = array_combine($keys, $vals);
    if ($result_type == MYSQL_ASSOC) {
        return $assoc;
    }
    return array_merge($num, $assoc);
}
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
// repairs a problem that was fixed in 2004.
// You should never have to run this script
set_time_limit(0);
$cli_only = true;
require_once "../inc/util_ops.inc";
// activate/deactivate script
if (1) {
    echo "\nThis script needs to be activated before it can be run.\nOnce you understand what the script does you can change the \nif (1) to if (0) at the top of the file to activate it.\nBe sure to deactivate the script after using it to make sure\nit is not accidentally run. \n";
    exit;
}
db_init();
$result = _mysql_query("select * from workunit where canonical_resultid=0");
while ($wu = _mysql_fetch_object($result)) {
    $r2 = _mysql_query("select count(*) from result where workunitid={$wu->id} and outcome=1 limit 1000");
    $x = _mysql_fetch_array($r2);
    _mysql_free_result($r2);
    $nsuccess = $x[0];
    $r2 = _mysql_query("select count(*) from result where workunitid={$wu->id} and server_state=2");
    $x = _mysql_fetch_array($r2);
    _mysql_free_result($r2);
    $nunsent = $x[0];
    if ($nsuccess >= 3 and $nunsent == 0) {
        echo "WU {$wu->id} has {$nsuccess} success, {$nunsent} unsent \n";
        _mysql_query("update workunit set need_validate=1 where id={$wu->id}");
    }
}