Completed
Push — 6.0 ( be0b6e...c47dd5 )
by liu
06:54 queued 10s
created

PDOQuery   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 30
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPdo() 0 3 1
A cursor() 0 12 2
1
<?php
2
// +----------------------------------------------------------------------
3
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
4
// +----------------------------------------------------------------------
5
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
6
// +----------------------------------------------------------------------
7
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
// +----------------------------------------------------------------------
9
// | Author: liu21st <[email protected]>
10
// +----------------------------------------------------------------------
11
declare (strict_types = 1);
12
13
namespace think\db\concern;
14
15
use PDO;
16
use PDOStatement;
17
18
/**
19
 * PDO查询支持
20
 */
21
trait PDOQuery
22
{
23
    /**
24
     * 执行查询但只返回PDOStatement对象
25
     * @access public
26
     * @return PDOStatement
27
     */
28
    public function getPdo(): PDOStatement
29
    {
30
        return $this->connection->pdo($this);
31
    }
32
33
    /**
34
     * 使用游标查找记录
35
     * @access public
36
     * @param mixed $data 数据
37
     * @return \Generator
38
     */
39
    public function cursor($data = null)
40
    {
41
        if (!is_null($data)) {
42
            // 主键条件分析
43
            $this->parsePkWhere($data);
0 ignored issues
show
Bug introduced by
It seems like parsePkWhere() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
            $this->/** @scrutinizer ignore-call */ 
44
                   parsePkWhere($data);
Loading history...
44
        }
45
46
        $this->options['data'] = $data;
0 ignored issues
show
Bug Best Practice introduced by
The property options does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
47
48
        $connection = clone $this->connection;
49
50
        return $connection->cursor($this);
51
    }
52
53
}
54