Code Duplication    Length = 16-18 lines in 2 locations

QueryTrait.php 2 locations

@@ 18-35 (lines=18) @@
15
{
16
    use ConnectionAbstractTrait;
17
18
    public function getWhereAndTraversable($table, array $where)
19
    // url/show
20
    {
21
        $qb = $this->getConnection()->createQueryBuilder();
22
23
        return $qb
24
            ->select('*')
25
            ->from($table)
26
            ->where(\call_user_func_array([$qb->expr(), 'andX'],
27
                array_map(
28
                    [$qb->expr(), 'eq'],
29
                    array_keys($where),
30
                    array_map([$qb, 'createNamedParameter'], array_values($where))
31
                )
32
            ))
33
            ->execute();
34
        // TODO: check if $stmt should be ->execute() like in getByUnique
35
    }
36
37
    public function findUniqueBy($table, array $where)
38
    {
@@ 129-144 (lines=16) @@
126
        $qb->execute();
127
    }
128
129
    public function deleteByUnique($table, array $id)
130
    { // TODO: assert unicity of index
131
        $qb = $this->getConnection()->createQueryBuilder();
132
133
        $qb
134
            ->delete($table)
135
            ->where(\call_user_func_array([$qb->expr(), 'andX'],
136
                array_map(
137
                    [$qb->expr(), 'eq'],
138
                    array_keys($id),
139
                    array_map([$qb, 'createNamedParameter'], array_values($id))
140
                )
141
            ))
142
            ->execute()
143
        ;
144
    }
145
146
    public function getManyToManyTraversable($base_table, $base_id, $link_base_id, $link_table, $link_distant_id, $distant_id, $distant_table, array $unique)
147
    // url/show