Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Category
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 getAllCategories
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/*
3 * Copyright (C) 2000-2021. Stephen Lawrence
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 */
19
20// Container for category info
21
22if (!defined('Category_class')) {
23    define('Category_class', 'true', false);
24
25    class Category
26    {
27        /**
28         * getAllCategories - Returns an array of all the categories
29         * @param PDO $pdo
30         * @returns array
31         */
32        public static function getAllCategories(PDO $pdo)
33        {
34            // query to get a list of available users
35            $query = "SELECT id, name FROM {$GLOBALS['CONFIG']['db_prefix']}category ORDER BY name";
36            $stmt = $pdo->prepare($query);
37            $stmt->execute();
38            $result = $stmt->fetchAll();
39
40            $categoryListArray = [];
41            foreach ($result as $row) {
42                $categoryListArray[] = $row;
43            }
44            return $categoryListArray;
45        }
46    }
47}