Code Duplication    Length = 13-14 lines in 12 locations

htdocs/kernel/module.php 1 location

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

htdocs/kernel/avatar.php 1 location

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

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|CriteriaCompo $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|CriteriaCompo $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/privmessage.php 1 location

@@ 298-310 (lines=13) @@
295
     * @param  CriteriaElement|CriteriaCompo $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|CriteriaCompo $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|CriteriaCompo $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|CriteriaCompo $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

htdocs/kernel/notification.php 1 location

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