Passed
Push — twig ( 8daeb7...5bf58a )
by Paweł
08:25 queued 03:50
created

SqlsrvPDO   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A lastInsertId() 0 3 2
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\db\mssql;
9
10
/**
11
 * This is an extension of the default PDO class of SQLSRV driver.
12
 * It provides workarounds for improperly implemented functionalities of the SQLSRV driver.
13
 *
14
 * @author Timur Ruziev <[email protected]>
15
 * @since 2.0
16
 */
17
class SqlsrvPDO extends \PDO
18
{
19
    /**
20
     * Returns value of the last inserted ID.
21
     *
22
     * SQLSRV driver implements [[PDO::lastInsertId()]] method but with a single peculiarity:
23
     * when `$sequence` value is a null or an empty string it returns an empty string.
24
     * But when parameter is not specified it works as expected and returns actual
25
     * last inserted ID (like the other PDO drivers).
26
     * @param string|null $sequence the sequence name. Defaults to null.
27
     * @return int last inserted ID value.
28
     */
29
    public function lastInsertId($sequence = null)
30
    {
31
        return !$sequence ? parent::lastInsertId() : parent::lastInsertId($sequence);
0 ignored issues
show
Bug Best Practice introduced by
The expression return ! $sequence ? par...lastInsertId($sequence) returns the type string which is incompatible with the documented return type integer.
Loading history...
32
    }
33
}
34