improve updating diskSpace entries

pull/3122/head
Isaac Connor 2017-10-23 17:02:04 -07:00
parent d2c8a0240a
commit b5e59efda5
1 changed files with 8 additions and 4 deletions

View File

@ -186,7 +186,10 @@ class Event {
return( $streamSrc );
} // end function getStreamSrc
function DiskSpace() {
function DiskSpace( $new='' ) {
if ( $new != '' ) {
$this->{'DiskSpace'} = $new;
}
if ( null === $this->{'DiskSpace'} ) {
$this->{'DiskSpace'} = folder_size( $this->Path() );
dbQuery( 'UPDATE Events SET DiskSpace=? WHERE Id=?', array( $this->{'DiskSpace'}, $this->{'Id'} ) );
@ -380,10 +383,11 @@ class Event {
}
public function save( ) {
$sql = 'UPDATE Events SET '.implode(' AND', array_map( function($field) {return $field.'=?';}, $fields ) ) . ' WHERE Id=?';
$values = array_map( function($field){return $this->{$field};}, $fields );
$sql = 'UPDATE Events SET '.implode(', ', array_map( function($field) {return $field.'=?';}, $this->fields ) ) . ' WHERE Id=?';
$values = array_map( function($field){return $this->{$field};}, $this->fields );
$values[] = $this->{'Id'};
dbQuery( $sql, NULL, $values );
dbQuery( $sql, $values );
}
} # end class