Code Duplication    Length = 20-20 lines in 3 locations

system/libraries/drivers/Database/Mssql.php 1 location

@@ 88-107 (lines=20) @@
85
    /**
86
     * @param string $sql
87
     */
88
    public function query($sql)
89
    {
90
        // Only cache if it's turned on, and only cache if it's not a write statement
91
        if ($this->db_config['cache'] and ! preg_match('#\b(?:INSERT|UPDATE|REPLACE|SET)\b#i', $sql)) {
92
            $hash = $this->query_hash($sql);
93
94
            if (! isset($this->query_cache[$hash])) {
95
                // Set the cached object
96
                $this->query_cache[$hash] = new Mssql_Result(mssql_query($sql, $this->link), $this->link, $this->db_config['object'], $sql);
97
            } else {
98
                // Rewind cached result
99
                $this->query_cache[$hash]->rewind();
100
            }
101
102
            // Return the cached query
103
            return $this->query_cache[$hash];
104
        }
105
106
        return new Mssql_Result(mssql_query($sql, $this->link), $this->link, $this->db_config['object'], $sql);
107
    }
108
109
    public function escape_table($table)
110
    {

system/libraries/drivers/Database/Mysql.php 1 location

@@ 80-99 (lines=20) @@
77
    /**
78
     * @param string $sql
79
     */
80
    public function query($sql)
81
    {
82
        // Only cache if it's turned on, and only cache if it's not a write statement
83
        if ($this->db_config['cache'] and ! preg_match('#\b(?:INSERT|UPDATE|REPLACE|SET|DELETE|TRUNCATE)\b#i', $sql)) {
84
            $hash = $this->query_hash($sql);
85
86
            if (! isset($this->query_cache[$hash])) {
87
                // Set the cached object
88
                $this->query_cache[$hash] = new Mysql_Result(mysql_query($sql, $this->link), $this->link, $this->db_config['object'], $sql);
89
            } else {
90
                // Rewind cached result
91
                $this->query_cache[$hash]->rewind();
92
            }
93
94
            // Return the cached query
95
            return $this->query_cache[$hash];
96
        }
97
98
        return new Mysql_Result(mysql_query($sql, $this->link), $this->link, $this->db_config['object'], $sql);
99
    }
100
101
    public function set_charset($charset)
102
    {

system/libraries/drivers/Database/Pgsql.php 1 location

@@ 67-86 (lines=20) @@
64
    /**
65
     * @param string $sql
66
     */
67
    public function query($sql)
68
    {
69
        // Only cache if it's turned on, and only cache if it's not a write statement
70
        if ($this->db_config['cache'] and ! preg_match('#\b(?:INSERT|UPDATE|SET)\b#i', $sql)) {
71
            $hash = $this->query_hash($sql);
72
73
            if (! isset($this->query_cache[$hash])) {
74
                // Set the cached object
75
                $this->query_cache[$hash] = new Pgsql_Result(pg_query($this->link, $sql), $this->link, $this->db_config['object'], $sql);
76
            } else {
77
                // Rewind cached result
78
                $this->query_cache[$hash]->rewind();
79
            }
80
81
            return $this->query_cache[$hash];
82
        }
83
84
        // Suppress warning triggered when a database error occurs (e.g., a constraint violation)
85
        return new Pgsql_Result(@pg_query($this->link, $sql), $this->link, $this->db_config['object'], $sql);
86
    }
87
88
    public function set_charset($charset)
89
    {