Test Failed
Pull Request — master (#52)
by David
03:47
created

TestCountryDao::getCountriesUsingUnion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace TheCodingMachine\TDBM\Dao;
4
5
use Porpaginas\Result;
6
use TheCodingMachine\TDBM\Test\Dao\Bean\CountryBean;
7
use TheCodingMachine\TDBM\Test\Dao\Generated\CountryBaseDao;
8
9
/**
10
 * The CountryDao class will maintain the persistence of CountryBean class into the country table.
11
 */
12
class TestCountryDao extends CountryBaseDao
13
{
14
    /**
15
     * @return CountryBean[]|Result
16
     */
17
    public function getCountriesByUserCount()
18
    {
19
        $sql = <<<SQL
20
SELECT country.*
21
FROM country
22
LEFT JOIN users ON users.country_id = country.id
23
GROUP BY country.id
24
ORDER BY COUNT(users.id) DESC
25
SQL;
26
27
        return $this->findFromRawSql($sql);
28
    }
29
30
    /**
31
     * @return CountryBean[]|Result
32
     */
33
    public function getCountriesUsingUnion()
34
    {
35
        $sql = <<<SQL
36
SELECT country.*
37
FROM country
38
WHERE country.id = 1
39
UNION
40
SELECT country.*
41
FROM country
42
WHERE country.id = 2
43
SQL;
44
45
        return $this->findFromRawSql($sql);
46
    }
47
}
48