Completed
Pull Request — master (#1523)
by
unknown
12:04
created

AliasMapper::findAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/**
4
 * ownCloud - Mail
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Tahaa Karim <[email protected]>
10
 * @copyright Tahaa Karim 2016
11
 */
12
13
namespace OCA\Mail\Db;
14
15
use OCP\AppFramework\Db\Mapper;
16
use OCP\IDb;
17
18
class AliasMapper extends Mapper {
19
20
	/**
21
	 * @param IDb $db
22
	 */
23
	public function __construct(IDb $db) {
24
		parent::__construct($db, 'mail_aliases');
25
	}
26
27
	/**
28
	 * @param int $id
29
	 * @return Alias[]
30
	 */
31
	public function find($id) {
32
		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?';
33
		return $this->findEntity($sql, [$id]);
34
	}
35
36
	/**
37
	 * @param int $accountId
38
	 * @return Alias
39
	 */
40
	public function findAll($accountId) {
41
		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE account_id = ?';
42
		return $this->findEntities($sql, [$accountId]);
43
	}
44
}
45