Code Duplication    Length = 8-11 lines in 5 locations

src/Connections/DatabaseTransactionsTrait.php 1 location

@@ 109-116 (lines=8) @@
106
     *
107
     * @return array All the records in the table.        
108
     */
109
    public function getAllRecords($table)
110
    {
111
        if (gettype($table) !== 'string') {
112
            throw new InvalidArgumentException("The parameter {$table} is not a string. A string is required instead.");
113
        }
114
115
        return $this->getPdo()->query("SELECT * FROM {$table}")->fetchAll();
116
    }
117
118
    /**
119
     * Update a record in the database.

src/Connections/MySqlConnection.php 2 locations

@@ 50-60 (lines=11) @@
47
     *
48
     * @return array The columns of the table.        
49
     */
50
    public function getColumns($table)
51
    {
52
        if (gettype($table) !== 'string') {
53
            throw new InvalidArgumentException("The parameter {$table} is not an string. A string is required instead.");
54
        }
55
56
        return $this->getPdo()->query("SELECT COLUMN_NAME
57
                                        FROM INFORMATION_SCHEMA.COLUMNS
58
                                        WHERE TABLE_NAME = N'{$table}' 
59
                                        AND TABLE_SCHEMA = N'{$this->_database}'")->fetchAll();
60
    }
61
62
    /**
63
     * Returns the Connection's PDO.
@@ 79-86 (lines=8) @@
76
     *
77
     * @return string The primary key of the table.
78
     */
79
    public function getPrimaryKey($table)
80
    {
81
        if (gettype($table) !== 'string') {
82
            throw new InvalidArgumentException("The parameter {$table} is not an string. A string is required instead.");
83
        }
84
85
        return $this->getPdo()->query("SHOW KEYS FROM {$table} WHERE Key_name = 'PRIMARY'")->fetchAll()[0]['Column_name'];
86
    }
87
}
88

src/Connections/PgSqlConnection.php 1 location

@@ 48-57 (lines=10) @@
45
     *
46
     * @return array The columns of the table.        
47
     */
48
    public function getColumns($table)
49
    {
50
        if (gettype($table) !== 'string') {
51
            throw new InvalidArgumentException("The parameter {$table} is not an string. A string is required instead.");
52
        }
53
54
        return $this->getPdo()->query("SELECT COLUMN_NAME
55
                                            FROM {$this->_database}.INFORMATION_SCHEMA.COLUMNS
56
                                            WHERE TABLE_NAME = N'{$table}'")->fetchAll();
57
    }
58
59
    /**
60
     * Returns the Connection's PDO.

src/Connections/SqliteConnection.php 1 location

@@ 45-54 (lines=10) @@
42
     *
43
     * @return array The columns of the table.        
44
     */
45
    public function getColumns($table)
46
    {
47
        if (gettype($table) !== 'string') {
48
            throw new InvalidArgumentException("The parameter {$table} is not an string. A string is required instead.");
49
        }
50
51
        var_dump($this->getPdo()->query("pragma table_info({$table})")->fetchAll());
52
53
        //return $this->getPdo()->query("pragma table_info(table_name)")->fetchAll();
54
    }
55
56
    /**
57
     * Returns the Connection's PDO.