row() static public method

Fetch a single query result row
static public row ( string $query, array $params = NULL ) : mixed
$query string query string
$params array query parameters
return mixed
Esempio n. 1
0
    $check_nrows = mysqli_num_rows($sample_check);
    if ($check_nrows > 0) {
        $check_row = mysqli_fetch_array($sample_check);
        extract($check_row);
        echo "<dt>From the sample set</dt><dd><a href=\"browse_sample.php?SampleID={$SampleID}\">{$SampleName}</a></dd>";
    }
}
$specinfo = DB::row("SELECT `SpecMaxFreq`, `ImageFFT` from `SoundsImages` WHERE `SoundID`=" . $SoundID . " AND `ImageType`='spectrogram'");
$SpecMaxFreq = $specinfo->SpecMaxFreq;
$ImageFFT = $specinfo->ImageFFT;
echo "<dt>Spectrogram settings</dt>\n\t\t\t\t\t\t\t<dd>Max frequency: {$SpecMaxFreq} Hz<br>\n\t\t\t\t\t\t\tFFT size: {$ImageFFT}</dd>\n";
if ($OtherSoundID != "") {
    echo "<dt>Custom ID</dt><dd>{$OtherSoundID}</dd>";
}
if ($SensorID != "") {
    $sensor = DB::row('SELECT `Recorder`, `Microphone`, `Notes` from `Sensors` WHERE `SensorID`=' . $SensorID);
    $Recorder = $sensor->Recorder;
    $Microphone = $sensor->Microphone;
    $SensorNotes = $sensor->Notes;
    echo "<dt>Sensor used</dt><dd>{$Recorder}, {$Microphone} ({$SensorNotes})</dd>";
} elseif ($SensorID == "1") {
    echo "<dt>Sensor used</dt><dd>Not set</dd>";
} else {
    echo "<dt>Sensor used</dt><dd>Not set</dd>";
}
if ($SiteElevation != "") {
    echo "<dt>Elevation</dt><dd>{$SiteElevation}</dd>\n";
}
if ($SiteURL != "") {
    echo "<dt>Site URL</dt><dd>{$SiteURL}</dd>\n";
}
Esempio n. 2
0
// Oops! We got Bob's info wrong! Lets fix it!
$user = array('username' => 'Bob', 'email' => '*****@*****.**');
$result = DB::update('users', $user, 3);
var_dump($result);
// Our moderators say that the "Troll" user needs to be deleted!
$result = DB::query('DELETE FROM users WHERE username = ?', array('Troll'));
var_dump($result);
/*
 * Select Queries
 */
// Count all the users
$result = DB::column('SELECT COUNT(*) FROM `users`');
var_dump('Total users: ' . $result);
br();
// Get user number 2 (John)
$result = DB::row('SELECT * FROM `users` WHERE id = ?', array(3));
var_dump($result);
br();
// Fetch all the users!
$result = DB::fetch('SELECT * FROM `users`');
var_dump($result);
br();
// Fetch users from "example.com"
$result = DB::fetch('SELECT * FROM `users` WHERE email LIKE ?', array('%example.com'));
var_dump($result);
br();
/*
 * Results
 */
print count(DB::$q) . " Queries Run:\n";
print_r(DB::$q);