DByte\DB::update PHP Method

update() static public method

Update a database row
static public update ( string $table, array $data, $value, $column = 'id' ) : integer | null
$table string name
$data array
return integer | null
    static function update($table, $data, $value, $column = 'id')
    {
        $keys = implode('`=?,`', array_keys($data));
        if ($statement = DB::query("UPDATE `{$table}` SET `{$keys}` = ? WHERE `{$column}` = ?", array_values($data + array($value)))) {
            return $statement->rowCount();
        }
    }

Usage Example

Beispiel #1
0
        if ($hidemarks != 1) {
            echo "<p><a href=\"db_filedetails.php?SoundID={$SoundID}&amp;hidemarks=1&amp;d={$d}&amp;hidekml={$hidekml}\">Hide marks on spectrogram</a><br>";
        } else {
            echo "<p><a href=\"db_filedetails.php?SoundID={$SoundID}&amp;d={$d}&amp;hidekml={$hidekml}\">Show marks on spectrogram</a><br>";
        }
        echo "<a href=\"#\" onclick=\"window.open('db_filemarks.php?SoundID={$SoundID}', 'marks', 'width=600,height=550,status=yes,resizable=yes,scrollbars=auto')\">Show list of marks</a><br>";
    }
}
echo "\n\t\t\t\t\t<dl class=\"dl-horizontal\">\n\t\t\t\t\t\t<dt>Original filename</dt>\n\t\t\t\t\t\t<dd>{$OriginalFilename}</dd>";
#Check if the file size is in the database
if ($FileSize == NULL || $FileSize == 0) {
    $file_filesize = filesize("sounds/sounds/{$ColID}/{$DirID}/{$OriginalFilename}");
    #$result_size = mysqli_query($connection, "UPDATE Sounds SET FileSize='$file_filesize' WHERE SoundID='$SoundID' LIMIT 1")
    #	or die (mysqli_error($connection));
    $this_array = array('FileSize' => $file_filesize);
    DB::update('Sounds', $this_array, $SoundID, 'SoundID');
    $FileSize = formatSize($file_filesize);
} else {
    $FileSize = formatSize($FileSize);
}
echo "<dt>File Format</dt><dd>{$SoundFormat}</dd>\n\t\t\t\t\t\t<dt>Sampling rate</dt><dd>{$SamplingRate} Hz</dd>\n\t\t\t\t\t\t<dt>Number of channels</dt><dd>{$Channels}</dd>";
echo "\n\t\t\t\t\t\t<dt>File size</dt>\n\t\t\t\t\t\t<dd>{$FileSize}</dd>";
if ($Duration > 60) {
    $formated_Duration = formatTime(round($Duration));
    echo "<dt>Duration</dt><dd>{$formated_Duration} (hh:mm:ss)</dd>";
} else {
    echo "<dt>Duration</dt><dd>{$Duration} seconds</dd>";
}
#Check if from a sample set
if ($pumilio_loggedin) {
    $sample_check = mysqli_query($connection, "SELECT Samples.SampleName,Samples.SampleID FROM\n\t\t\t\t\t\t\tSamples,SampleMembers WHERE Samples.SampleID=SampleMembers.SampleID \n\t\t\t\t\t\t\tAND SampleMembers.SoundID='{$SoundID}'") or die(mysqli_error($connection));
All Usage Examples Of DByte\DB::update