コード例 #1
0
require_once '../includes/autoloads.php';
$problem_ids = array();
//Get the campuses...
$conn = connect();
$all_campuses_query = 'SELECT Campus_ID FROM Campuses';
$result = mysql_query($all_campuses_query, $conn);
while ($row = mysql_fetch_assoc($result)) {
    //Query the campus
    $query = next_dropdowns_query(array('campus' => $row['Campus_ID']));
    $campus_result = mysql_query($query, $conn);
    if (mysql_num_rows($campus_result) == 0) {
        $problem_ids[] = $row['Campus_ID'];
    } else {
        $campus_row = mysql_fetch_assoc($campus_result);
        if (!$campus_row['Term_ID']) {
            update_classes_from_bookstore($campus_row);
            $campus_result = mysql_query($query, $conn);
            if (mysql_num_rows($campus_result) == 0) {
                $problem_ids[] = $row['Campus_ID'];
            } else {
                $campus_row = mysql_fetch_assoc($campus_result);
                if (!$campus_row['Term_ID']) {
                    $problem_ids[] = $row['Campus_ID'];
                }
            }
        }
    }
}
echo implode(',', $problem_ids);
?>
コード例 #2
0
ファイル: api.php プロジェクト: nicefirework/Open-Textbooks
 $query = next_dropdowns_query(array($sent_name => $sent_val));
 $end = microtime(true);
 $json['first_query_time'] = round($end - $start, 3) * 1000;
 if (!($result = mysql_query($query))) {
     $json['status'] = 'Error: SQL query based on ' . $sent_name . '=' . $sent_val . ' yielded error: ' . mysql_error();
 } else {
     if (mysql_num_rows($result) == 0) {
         $json['status'] = 'Error: SQL query based on ' . $sent_name . '=' . $sent_val . ' yielded no results';
     } else {
         $next_name = $names_array[$sent_dd + 1];
         $next_id = $ids_array[$sent_dd + 1];
         $row = mysql_fetch_assoc($result);
         if (!$row[$next_id]) {
             $start = microtime(true);
             mysql_close($conn);
             update_classes_from_bookstore($row);
             //make bookstore requests to update db cache with what we want.. note that this attempts 3 times..
             if (!($conn = connect())) {
                 $json['status'] = mysql_error();
                 die(json_encode($json));
             }
             $end = microtime(true);
             $json['scrape_and_cache_update_time'] = round($end - $start, 3) * 1000;
             //now we try to the query again..
             $start = microtime(true);
             if (!($result = mysql_query($query))) {
                 $json['status'] = 'Error: SQL query based on ' . $sent_name . '=' . $sent_val . ' yielded error: ' . mysql_error();
             } else {
                 if (mysql_num_rows($result) == 0) {
                     $json['status'] = 'Error: SQL query based on ' . $sent_name . '=' . $sent_val . ' yielded no results';
                 }