ResourceTbl   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getNextId() 0 11 1
1
<?php
2
3
namespace Auth\Model;
4
5
use Drone\Db\TableGateway\TableGateway;
6
7
class ResourceTbl extends TableGateway
8
{
9
    /**
10
     * Returns the next primary key in the table
11
     *
12
     * @return string
13
     */
14
    public function getNextId()
15
    {
16
        $table = $this->getEntity()->getTableName();
17
18
        $sql = "SELECT CASE WHEN MAX(RESOURCE_ID) IS NULL THEN 1 ELSE MAX(RESOURCE_ID) + 1 END AS RESOURCE_ID FROM $table";
19
20
        $this->getDriver()->getDb()->execute($sql);
21
        $rowset = $this->getDriver()->getDb()->getArrayResult();
22
        $row = array_shift($rowset);
23
24
        return $row["RESOURCE_ID"];
25
    }
26
}