AbstractDatabasePDOO::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 5

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 21
rs 9.9
c 2
b 0
f 0
cc 3
nc 5
nop 1
1
<?php
2
3
/**
4
 * KNUT7 K7F (https://marciozebedeu.com/)
5
 * KNUT7 K7F (tm) : Rapid Development Framework (https://marciozebedeu.com/)
6
 *
7
 * Licensed under The MIT License
8
 * For full copyright and license information, please see the LICENSE.txt
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @link      https://github.com/knut7/framework/ for the canonical source repository
12
 * @copyright (c) 2015.  KNUT7  Software Technologies AO Inc. (https://marciozebedeu.com/)
13
 * @license   https://marciozebedeu.com/license/new-bsd New BSD License
14
 * @author    Marcio Zebedeu - [email protected]
15
 * @version   1.0.2
16
 */
17
18
namespace Ballybran\Database\Drives;
19
20
use Ballybran\Database\DBconnection;
21
use Ballybran\Helpers\vardump\Vardump;
0 ignored issues
show
Bug introduced by
The type Ballybran\Helpers\vardump\Vardump was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use PDO;
23
use function var_dump;
24
25
class AbstractDatabasePDOO
26
{
27
28
    public $conn;
29
    public $stmt;
30
    /**
31
     * @var array
32
     */
33
    private $param;
0 ignored issues
show
introduced by
The private property $param is not used, and could be removed.
Loading history...
34
    private $_instances;
35
    private $params;
36
37
    /**
38
     * DatabasePDOO constructor.
39
     * @param array $param
40
     */
41
    public function __construct($params)
42
    {
43
        $this->params = $params;
44
45
        try {
46
47
48
            $this->_instances = new PDO("mysql:host=localhost;port=8889;dbname=apweb", "root", "root");
49
50
            $attributes = array(
51
                "AUTOCOMMIT", "ERRMODE", "CASE", "CLIENT_VERSION", "CONNECTION_STATUS",
52
                "ORACLE_NULLS", "PERSISTENT", "SERVER_INFO", "SERVER_VERSION"
53
            );
54
            foreach ($attributes as $value) {
55
                $this->_instances->getAttribute(constant("PDO::ATTR_$value")) . "\n";
56
            }
57
        } catch (\PDOException $exc) {
58
            throw new \Exception('Failed to connect to database. Reason: ' . $exc->getMessage());
59
        }
60
61
        return $this->_instances;
62
    }
63
64
    public function select($select)
65
    {
66
67
68
        $stmt = $this->_instances->prepare("SELECT * FROM $select");
69
        $stmt->execute();
70
        $stmt->fetchAll(\PDO::FETCH_ASSOC);
71
72
73
        return $this;
74
75
    }
76
77
    public function table($table)
78
    {
79
        echo "$table";
80
        return $this;
81
    }
82
83
    public function Backup($localation)
0 ignored issues
show
Unused Code introduced by
The parameter $localation is not used and could be removed. ( Ignorable by Annotation )

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

83
    public function Backup(/** @scrutinizer ignore-unused */ $localation)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
84
    {
85
86
    }
87
88
}