예제 #1
0
function get_weight($id_c)
{
    if (get_trace($id_c) == 0) {
        return get_standard_weight($id_c);
    } else {
        $weight = get_token(get_trace($id_c));
        return $weight;
    }
}
예제 #2
0
function do_pdo($driver, $host, $db, $charset, $user, $password, $query)
{
    global $db_connect_result, $db_data;
    try {
        // create new pdo object
        $pdo = new PDO("{$driver}:host={$host};dbname={$db};charset={$charset}", $user, $password);
        // Set Errorhandling to Exception
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        // get fields from table
        $q = $pdo->prepare("DESCRIBE Country;");
        $q->execute();
        $table_fields = $q->fetchAll(PDO::FETCH_COLUMN);
        // get table data
        $q = $pdo->query($query);
        $results = $q->fetchAll(PDO::FETCH_ASSOC);
        // close the connection
        $pdo = null;
    } catch (PDOException $e) {
        $db_connect_result = '<p style="text-align:center"><img src="images/red-cross.png" style="margin-right:5px;margin-bottom:-3px; alt="" /><strong><span style="color:red">Connect failed!</span></strong></p>' . "\n\t";
        $db_connect_result .= get_trace($e);
        return;
    }
    // create html data table
    $db_data .= "<table>\n";
    $db_data .= " <tr>\n  ";
    // add table headers from cols
    foreach ($table_fields as $field) {
        $db_data .= '<th>' . $field . '</th>';
    }
    $db_data .= "\n </tr>\n";
    // iterate through each record
    foreach ($results as $a) {
        $db_data .= " <tr>\n  ";
        foreach ($a as $v) {
            $db_data .= '<td>' . $v . '</td>';
        }
        $db_data .= "\n </tr>\n";
    }
    $db_data .= "</table>\n";
    $db_data .= "<p>Returned " . $q->rowCount() . " rows for " . $q->columnCount() . " fields.</p>\n";
    $db_connect_result = '<img src="images/tick-clean.png" style="margin-right:5px;margin-bottom:-3px;" alt="" /><strong><span style="color:green">Successful</span></strong>';
}
예제 #3
0
function get_weight($id_c)
{
    if (get_trace($id_c) == 0) {
        return get_standard_weight($id_c);
        //that si the case we understand
    } else {
        $weight = get_token(get_trace($id_c));
        if ($weight == 0) {
            return get_standard_weight($id_c);
        } else {
            return $weight;
        }
    }
}