Code Duplication    Length = 13-14 lines in 12 locations

htdocs/kernel/avatar.php 1 location

@@ 322-334 (lines=13) @@
319
     * @param  CriteriaElement $criteria
320
     * @return int
321
     */
322
    public function getCount(CriteriaElement $criteria = null)
323
    {
324
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('avatar');
325
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
326
            $sql .= ' ' . $criteria->renderWhere();
327
        }
328
        if (!$result = $this->db->query($sql)) {
329
            return 0;
330
        }
331
        list($count) = $this->db->fetchRow($result);
332
333
        return $count;
334
    }
335
336
    /**
337
     * Add user

htdocs/kernel/comment.php 1 location

@@ 483-495 (lines=13) @@
480
     *
481
     * @return int Count
482
     **/
483
    public function getCount(CriteriaElement $criteria = null)
484
    {
485
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('xoopscomments');
486
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
487
            $sql .= ' ' . $criteria->renderWhere();
488
        }
489
        if (!$result = $this->db->query($sql)) {
490
            return 0;
491
        }
492
        list($count) = $this->db->fetchRow($result);
493
494
        return $count;
495
    }
496
497
    /**
498
     * Delete multiple comments

htdocs/kernel/configitem.php 1 location

@@ 432-445 (lines=14) @@
429
     * @param  CriteriaElement $criteria {@link CriteriaElement}
430
     * @return int             Count of configs matching $criteria
431
     */
432
    public function getCount(CriteriaElement $criteria = null)
433
    {
434
        $sql   = 'SELECT * FROM ' . $this->db->prefix('config');
435
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
436
            $sql .= ' ' . $criteria->renderWhere();
437
        }
438
        $result = $this->db->query($sql);
439
        if (!$result) {
440
            return false;
441
        }
442
        list($count) = $this->db->fetchRow($result);
443
444
        return $count;
445
    }
446
}
447

htdocs/kernel/image.php 1 location

@@ 335-347 (lines=13) @@
332
     * @param  CriteriaElement $criteria {@link CriteriaElement}
333
     * @return int
334
     **/
335
    public function getCount(CriteriaElement $criteria = null)
336
    {
337
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('image');
338
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
339
            $sql .= ' ' . $criteria->renderWhere();
340
        }
341
        if (!$result = $this->db->query($sql)) {
342
            return 0;
343
        }
344
        list($count) = $this->db->fetchRow($result);
345
346
        return $count;
347
    }
348
349
    /**
350
     * Get a list of images

htdocs/kernel/module.php 1 location

@@ 889-901 (lines=13) @@
886
     * @param  CriteriaElement $criteria {@link CriteriaElement}
887
     * @return int
888
     */
889
    public function getCount(CriteriaElement $criteria = null)
890
    {
891
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('modules');
892
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
893
            $sql .= ' ' . $criteria->renderWhere();
894
        }
895
        if (!$result = $this->db->query($sql)) {
896
            return 0;
897
        }
898
        list($count) = $this->db->fetchRow($result);
899
900
        return $count;
901
    }
902
903
    /**
904
     * returns an array of module names

htdocs/kernel/notification.php 1 location

@@ 376-388 (lines=13) @@
373
     *
374
     * @return int Count
375
     **/
376
    public function getCount(CriteriaElement $criteria = null)
377
    {
378
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('xoopsnotifications');
379
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
380
            $sql .= ' ' . $criteria->renderWhere();
381
        }
382
        if (!$result = $this->db->query($sql)) {
383
            return 0;
384
        }
385
        list($count) = $this->db->fetchRow($result);
386
387
        return $count;
388
    }
389
390
    /**
391
     * Delete multiple notifications

htdocs/kernel/privmessage.php 1 location

@@ 298-310 (lines=13) @@
295
     * @param  CriteriaElement $criteria = null     {@link CriteriaElement} object
296
     * @return int
297
     **/
298
    public function getCount(CriteriaElement $criteria = null)
299
    {
300
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('priv_msgs');
301
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
302
            $sql .= ' ' . $criteria->renderWhere();
303
        }
304
        if (!$result = $this->db->query($sql)) {
305
            return 0;
306
        }
307
        list($count) = $this->db->fetchRow($result);
308
309
        return $count;
310
    }
311
312
    /**
313
     * Mark a message as read

htdocs/kernel/tplfile.php 1 location

@@ 434-446 (lines=13) @@
431
     * @param  CriteriaElement $criteria
432
     * @return int
433
     */
434
    public function getCount(CriteriaElement $criteria = null)
435
    {
436
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('tplfile');
437
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
438
            $sql .= ' ' . $criteria->renderWhere();
439
        }
440
        if (!$result = $this->db->query($sql)) {
441
            return 0;
442
        }
443
        list($count) = $this->db->fetchRow($result);
444
445
        return $count;
446
    }
447
448
    /**
449
     * getModuleTplCount

htdocs/kernel/tplset.php 1 location

@@ 291-303 (lines=13) @@
288
     * @param  CriteriaElement $criteria {@link CriteriaElement}
289
     * @return int             Count of tplsets matching $criteria
290
     */
291
    public function getCount(CriteriaElement $criteria = null)
292
    {
293
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('tplset');
294
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
295
            $sql .= ' ' . $criteria->renderWhere();
296
        }
297
        if (!$result = $this->db->query($sql)) {
298
            return 0;
299
        }
300
        list($count) = $this->db->fetchRow($result);
301
302
        return $count;
303
    }
304
305
    /**
306
     * get a list of tplsets matchich certain conditions

htdocs/kernel/group.php 1 location

@@ 446-459 (lines=14) @@
443
     * @param  CriteriaElement $criteria {@link CriteriaElement} conditions to meet
444
     * @return int
445
     */
446
    public function getCount(CriteriaElement $criteria = null)
447
    {
448
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('groups_users_link');
449
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
450
            $sql .= ' ' . $criteria->renderWhere();
451
        }
452
        $result = $this->db->query($sql);
453
        if (!$result) {
454
            return 0;
455
        }
456
        list($count) = $this->db->fetchRow($result);
457
458
        return $count;
459
    }
460
461
    /**
462
     * delete all memberships meeting the conditions

htdocs/kernel/groupperm.php 1 location

@@ 280-293 (lines=14) @@
277
     *
278
     * @return int
279
     */
280
    public function getCount(CriteriaElement $criteria = null)
281
    {
282
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('group_permission');
283
        if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
284
            $sql .= ' ' . $criteria->renderWhere();
285
        }
286
        $result = $this->db->query($sql);
287
        if (!$result) {
288
            return 0;
289
        }
290
        list($count) = $this->db->fetchRow($result);
291
292
        return $count;
293
    }
294
295
    /**
296
     * Delete all permissions by a certain criteria

htdocs/kernel/online.php 1 location

@@ 178-190 (lines=13) @@
175
     *
176
     * @return bool
177
     */
178
    public function getCount(CriteriaElement $criteria = null)
179
    {
180
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('online');
181
        if (is_object($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
182
            $sql .= ' ' . $criteria->renderWhere();
183
        }
184
        if (!$result = $this->db->query($sql)) {
185
            return false;
186
        }
187
        list($ret) = $this->db->fetchRow($result);
188
189
        return $ret;
190
    }
191
}
192