Code Duplication    Length = 43-43 lines in 4 locations

class/class.datatype.php 1 location

@@ 108-150 (lines=43) @@
105
     * @param bool     $forceQuery
106
     * @return bool true if insertion is succesful, false if unsuccesful
107
     */
108
    public function insertDataType($obj, $forceQuery = false)
109
    {
110
        $tablename    = 'efqdiralpha1_dtypes';
111
        $keyName      = 'dtypeid';
112
        $excludedVars = array();
113
        if ($obj instanceof efqDataType) {
114
            // Variable part of this function ends. From this line you can copy
115
            // this function for similar object handling functions.
116
            $obj->cleanVars();
117
            $cleanvars = $obj->cleanVars;
118
        } else {
119
            return false;
120
        }
121
        $countVars = count($cleanvars);
122
        $i         = 1;
123
        $strFields = '';
124
        $strValues = '';
125
        foreach ($cleanvars as $k => $v) {
126
            if (!in_array($k, $excludedVars)) {
127
                $strFields .= $k;
128
                $strValues .= "'" . $v . "'";
129
                if ($i < $countVars) {
130
                    $strFields .= ', ';
131
                    $strValues .= ', ';
132
                }
133
                $i++;
134
            }
135
        }
136
        $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues);
137
        if ($forceQuery) {
138
            if ($this->db->queryF($sql)) {
139
                $itemid = $this->db->getInsertId();
140
                $obj->setVar($keyName, $itemid);
141
142
                return true;
143
            }
144
        } else {
145
            if ($this->db->query($sql)) {
146
                $itemid = $this->db->getInsertId();
147
                $obj->setVar($keyName, $itemid);
148
149
                return true;
150
            }
151
        }
152
153
        return false;

class/class.directory.php 1 location

@@ 263-305 (lines=43) @@
260
     * @param bool     $forceQuery
261
     * @return bool true if insertion is succesful, false if unsuccesful
262
     */
263
    public function insertDirectory($obj, $forceQuery = false)
264
    {
265
        $tablename    = 'efqdiralpha1_dir';
266
        $keyName      = 'dirid';
267
        $excludedVars = array();
268
        if ($obj instanceof efqDirectory) {
269
            // Variable part of this function ends. From this line you can copy
270
            // this function for similar object handling functions.
271
            $obj->cleanVars();
272
            $cleanvars = $obj->cleanVars;
273
        } else {
274
            return false;
275
        }
276
        $countVars = count($cleanvars);
277
        $i         = 1;
278
        $strFields = '';
279
        $strValues = '';
280
        foreach ($cleanvars as $k => $v) {
281
            if (!in_array($k, $excludedVars)) {
282
                $strFields .= $k;
283
                $strValues .= "'" . $v . "'";
284
                if ($i < $countVars) {
285
                    $strFields .= ', ';
286
                    $strValues .= ', ';
287
                }
288
                $i++;
289
            }
290
        }
291
        $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues);
292
        if ($forceQuery) {
293
            if ($this->db->queryF($sql)) {
294
                $itemid = $this->db->getInsertId();
295
                $obj->setVar($keyName, $itemid);
296
297
                return true;
298
            }
299
        } else {
300
            if ($this->db->query($sql)) {
301
                $itemid = $this->db->getInsertId();
302
                $obj->setVar($keyName, $itemid);
303
304
                return true;
305
            }
306
        }
307
308
        return false;

class/class.itemtype.php 1 location

@@ 98-140 (lines=43) @@
95
     * @param bool     $forceQuery
96
     * @return bool true if insertion is succesful, false if unsuccesful
97
     */
98
    public function insert($obj, $forceQuery = false)
99
    {
100
        $tablename    = 'efqdiralpha1_itemtypes';
101
        $keyName      = 'typeid';
102
        $excludedVars = array();
103
        if ($obj instanceof efqItemType) {
104
            // Variable part of this function ends. From this line you can copy
105
            // this function for similar object handling functions.
106
            $obj->cleanVars();
107
            $cleanvars = $obj->cleanVars;
108
        } else {
109
            return false;
110
        }
111
        $countVars = count($cleanvars);
112
        $i         = 1;
113
        $strFields = '';
114
        $strValues = '';
115
        foreach ($cleanvars as $k => $v) {
116
            if (!in_array($k, $excludedVars)) {
117
                $strFields .= $k;
118
                $strValues .= "'" . $v . "'";
119
                if ($i < $countVars) {
120
                    $strFields .= ', ';
121
                    $strValues .= ', ';
122
                }
123
                $i++;
124
            }
125
        }
126
        $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues);
127
        if ($forceQuery) {
128
            if ($this->db->queryF($sql)) {
129
                $itemid = $this->db->getInsertId();
130
                $obj->setVar($keyName, $itemid);
131
132
                return true;
133
            }
134
        } else {
135
            if ($this->db->query($sql)) {
136
                $itemid = $this->db->getInsertId();
137
                $obj->setVar($keyName, $itemid);
138
139
                return true;
140
            }
141
        }
142
143
        return false;

class/class.offer.php 1 location

@@ 108-150 (lines=43) @@
105
     * @param bool     $forceQuery
106
     * @return bool true if insertion is succesful, false if unsuccesful
107
     */
108
    public function insertOffer($obj, $forceQuery = false)
109
    {
110
        $tablename    = 'efqdiralpha1_subscr_offers';
111
        $keyName      = 'offerid';
112
        $excludedVars = array('level', 'typename');
113
        if ($obj instanceof efqSubscriptionOffer) {
114
            // Variable part of this function ends. From this line you can copy
115
            // this function for similar object handling functions.
116
            $obj->cleanVars();
117
            $cleanvars = $obj->cleanVars;
118
        } else {
119
            return false;
120
        }
121
        $countVars = count($cleanvars);
122
        $i         = 1;
123
        $strFields = '';
124
        $strValues = '';
125
        foreach ($cleanvars as $k => $v) {
126
            if (!in_array($k, $excludedVars)) {
127
                $strFields .= $k;
128
                $strValues .= "'" . $v . "'";
129
                if ($i < $countVars) {
130
                    $strFields .= ', ';
131
                    $strValues .= ', ';
132
                }
133
                $i++;
134
            }
135
        }
136
        $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues);
137
        if ($forceQuery) {
138
            if ($this->db->queryF($sql)) {
139
                $itemid = $this->db->getInsertId();
140
                $obj->setVar($keyName, $itemid);
141
142
                return true;
143
            }
144
        } else {
145
            if ($this->db->query($sql)) {
146
                $itemid = $this->db->getInsertId();
147
                $obj->setVar($keyName, $itemid);
148
149
                return true;
150
            }
151
        }
152
153
        return false;