Passed
Push — master ( c5754d...1955b9 )
by Darío
07:59 queued 02:30
created

UserConnectionsTable::getNextId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Workarea\Model;
4
5
use Drone\Db\TableGateway\TableGateway;
6
7
class UserConnectionsTable extends TableGateway
8
{
9
    /**
10
     * Returns the max primary key to add
11
     *
12
     * @return string
13
     */
14
    public function getNextId()
15
    {
16
        $table = $this->getEntity()->getTableName();
17
18
        $sql = "SELECT MAX(USER_CONN_ID) USER_CONN_ID FROM $table";
19
20
        $this->getDriver()->getDb()->execute($sql);
21
        $rowset = $this->getDriver()->getDb()->getArrayResult();
22
        $row = array_shift($rowset);
23
24
        return is_null($row["USER_CONN_ID"]) ? 1 : (integer) $row["USER_CONN_ID"] + 1;
25
    }
26
}