MphpD
v1.0.0 Documentation GitHub

# DB

This subclass is used to interact with and retrieve information from MPD's database.

    MphpD::db() : DB

## Methods

### __construct

This class is not intended for direct usage. Use `MphpD::db()` instead to retrieve an instance of this class.

    DB::__construct(FloFaber\MphpD\MphpD $mphpd) : mixed

#### Parameters

@param \MphpD $mphpd

#### Returns `mixed`

### albumart

Returns the albumart (binary!) for given song.

    DB::albumart(string $songuri) : mixed

#### Parameters

@param string $songuri

#### Returns `mixed`

false|string binary `string` on success or `false` on failure.

### count

Counts the number of songs and their playtime matching the specified Filter.

    DB::count(FloFaber\MphpD\Filter $filter, string $group = '') : mixed

#### Parameters

@param \Filter $filter

- ##### $group

  A tag name like `artist` by which the results will be grouped.

  If omitted returns an associative array containing a "songs" and "playtime" key.

  If specified an array of associative array will be returned.

#### Returns `mixed`

array|false `array` on success or `false` on failure.

### fingerprint

Calculate the song's fingerprint

    DB::fingerprint(string $uri) : mixed

#### Parameters

- ##### $uri

  URI to the file.

#### Returns `mixed`

string|false fingerprint on success or `false` on failure.

### find

Case-sensitive search for songs matching Filter and return an array of associative array of found songs.

    DB::find(FloFaber\MphpD\Filter $filter, string $sort = '', array $window = []) : mixed

#### Parameters

@param \Filter $filter

- ##### $sort

  Tag name to sort by. Like artist. If prefixed with `-` it will be sorted descending.

  If omitted the order is undefined.

- ##### $window

  Retrieve only a given portion

#### Returns `mixed`

array|false `array` on success and `false` on failure.

### list

Lists unique tags values of the specified type. `$type` can be any tag supported by MPD.

    DB::list(string $type, ?FloFaber\MphpD\Filter $filter = null, string $group = '') : mixed

#### Parameters

- ##### $type

  Any tag supported by MPD. Like artist or album.

@param \Filter|null $filter

- ##### $group

  Tag name by which the result gets grouped. Like artist or album.

  If omitted returns an array of unique tag values of the specified type.

  If specified returns an array of associative arrays containing the grouped result.

#### Returns `mixed`

array|false `array` on success or `false` on failure.

### ls

List files,directories and playlists in `$uri`

    DB::ls(string $uri, bool $metadata = , bool $recursive = ) : mixed

#### Parameters

- ##### $uri

  Directory URI.

- ##### $metadata

  Specifies if additional information should be included.

- ##### $recursive

  Specified if files and directories should be listed recursively.

#### Returns `mixed`

array|false `array` containing the keys `files`, `directories` and `playlists` on success or `false` on failure.

### read_comments

Read "comments" from the specified file. The meaning of these "comments" depend on the codec. For an OGG file this lists the vorbis commands.

    DB::read_comments(string $uri) : mixed

#### Parameters

- ##### $uri

  Song URI.

#### Returns `mixed`

array|false `array` on success or `false` on failure.

### read_picture

Returns a picture of `$uri` by reading embedded pictures from binary tags.

    DB::read_picture(string $uri) : mixed

#### Parameters

- ##### $uri

  Song URI.

#### Returns `mixed`

false|string binary-data `string` on success and `false` on failure.

### search

Case-INsensitive search for matching songs and returns an array of associative arrays containing song information.

    DB::search(FloFaber\MphpD\Filter $filter, string $sort = '', array $window = []) : mixed

#### Parameters

@param \Filter $filter

@param string $sort

@param array $window

#### Returns `mixed`

array|false `array` on success or `false` on failure.

### update

Update the Database and return the Job-ID.

    DB::update(string $uri = '', bool $rescan = , bool $force = ) : mixed

#### Parameters

- ##### $uri

  Optional. Only update the given path. Omit or specify an empty string to update everything.

- ##### $rescan

  If set to `true` also rescan unmodified files.

- ##### $force

  If set to `false` and an update Job is already running, just return its ID.

  If true and an update Job is already running it starts another one and returns the ID of the new Job.

#### Returns `mixed`

int|false Job-ID on success or `false` on failure.

© 2023 Florian Faber