2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4 * Music Player Daemon API
8 * LICENSE: This source file is subject to version 3.01 of the PHP license
9 * that is available thorugh the world-wide-web at the following URI:
10 * http://www.php.net/license/3_01.txt. If you did not receive a copy of
11 * the PHP License and are unable to obtain it through the web, please
12 * send a note to license@php.net so we can mail you a copy immediately.
14 * @category Networking
16 * @author Graham Christensen <graham.christensen@itrebal.com>
17 * @copyright 2006 Graham Christensen
18 * @license http://www.php.net/license/3_01.txt
23 * API for the database portion of Music Player Daemon commands
25 * Used for maintaining and working with the MPD database
27 * @category Networking
29 * @author Graham Christensen <graham.christensen@itrebal.com>
30 * @copyright 2006 Graham Christensen
31 * @license http://www.php.net/license/3_01.txt
34 class Net_MPD_Database extends Net_MPD_Common
37 * Case sensitive search for data in the database
39 * @param array $params array('search_field' => 'search for')
40 * @param bool $caseSensitive True for case sensitivity, false for not [default false]
43 public function find($params, $caseSensitive = false)
46 foreach($params as $key => $value) {
50 $cmd = $caseSensitive ? 'find' : 'search';
52 $out = $this->runCommand($cmd, $prms);
53 if (!isset($out['file'])) {
62 * List all metadata of matches to the search
64 * @param string $metadata1 metadata to list
65 * @param string $metadata2 metadata field to search in, optional
66 * @param string $search data to search for in search field,
67 * required if search field provided
70 public function getMetadata($metadata1, $metadata2 = null, $search = null)
72 //Make sure that if metadata2 is set, search is as well
73 if (!is_null($metadata2)) {
74 if (is_null($search)) {
78 if (!is_null($metadata2)) {
79 $out = $this->runCommand('list', array($metadata1, $metadata2, $search), 1);
81 $out = $this->runCommand('list', $metadata1, 1);
83 return $out[$metadata1];
89 * Lists all files and folders in the directory recursively
91 * @param $dir string directory to start in, optional
94 public function getAll($dir = '')
96 return $this->runCommand('listall', $dir, 1);
102 * Lists all files/folders recursivly, listing any related informaiton
104 * @param $dir string directory to start in, optional
107 public function getAllInfo($dir = '')
109 return $this->runCommand('listallinfo', $dir);
113 * Lists content of the directory
115 * @param $dir string directory to work in, optional
118 public function getInfo($dir = '')
120 return $this->runCommand('lsinfo', $dir);