Code Duplication    Length = 7-13 lines in 11 locations

main/inc/lib/statsUtils.lib.inc.php 1 location

@@ 32-42 (lines=11) @@
29
     * @param sql : a sql query (as a string)
30
     * @desc Return many results of a query in a 1 column tab
31
     */
32
    public static function getManyResults1Col($sql)
33
    {
34
        $res = Database::query($sql);
35
        if ($res !== false) {
36
            $i = 0;
37
            while ($resA = Database::fetch_array($res, 'NUM')) {
38
                $resu[$i++] = $resA[0];
39
            }
40
        }
41
        return $resu;
42
    }
43
44
    /**
45
     * @author Sebastien Piraux <[email protected]>

main/inc/lib/urlmanager.lib.php 1 location

@@ 140-149 (lines=10) @@
137
     * @author Julio Montoya
138
     * @return int count of urls
139
     * */
140
    public static function url_count()
141
    {
142
        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
143
        $sql = "SELECT count(id) as count_result FROM $table_access_url";
144
        $res = Database::query($sql);
145
        $url = Database::fetch_array($res,'ASSOC');
146
        $result = $url['count_result'];
147
148
        return $result;
149
    }
150
151
    /**
152
     * Gets the id, url, description, and active status of ALL URLs

main/inc/lib/TicketManager.php 1 location

@@ 121-132 (lines=12) @@
118
    /**
119
     * @return int
120
     */
121
    public static function getCategoriesCount()
122
    {
123
        $table = Database::get_main_table(TABLE_TICKET_CATEGORY);
124
125
        $sql = "SELECT count(id) count
126
                FROM $table ";
127
128
        $result = Database::query($sql);
129
        $category = Database::fetch_array($result);
130
131
        return $category['count'];
132
    }
133
134
    /**
135
     * @param int $id

main/inc/lib/legal.lib.php 1 location

@@ 248-259 (lines=12) @@
245
	 * Gets the number of terms and conditions available
246
	 * @return int
247
	 */
248
	public static function count()
249
    {
250
		$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
251
		$sql = "SELECT count(*) as count_result
252
		        FROM $legal_conditions_table
253
		        ORDER BY id DESC ";
254
		$result = Database::query($sql);
255
		$url = Database::fetch_array($result,'ASSOC');
256
		$result = $url['count_result'];
257
258
		return $result;
259
	}
260
261
	/**
262
	 * Get type of terms and conditions

main/inc/lib/myspace.lib.php 4 locations

@@ 884-892 (lines=9) @@
881
     *
882
     * @return integer Total number of courses
883
     */
884
    public static function get_total_number_courses()
885
    {
886
        $table = Database :: get_main_table(TABLE_MAIN_COURSE);
887
        $sql = "SELECT COUNT(id) count FROM $table";
888
        $result = Database::query($sql);
889
        $row = Database::fetch_assoc($result);
890
891
        return $row['count'];
892
    }
893
894
    /**
895
     * Get data for the courses
@@ 1221-1229 (lines=9) @@
1218
     *
1219
     * @return integer Total number of sessions
1220
     */
1221
    public static function get_total_number_sessions()
1222
    {
1223
        $table = Database :: get_main_table(TABLE_MAIN_SESSION);
1224
        $sql = "SELECT COUNT(id) count FROM $table";
1225
        $result = Database::query($sql);
1226
        $row = Database::fetch_assoc($result);
1227
1228
        return $row['count'];
1229
    }
1230
1231
    /**
1232
     * Get data for the sessions
@@ 1875-1883 (lines=9) @@
1872
     * @version Dokeos 1.8.6
1873
     * @since October 2008
1874
     */
1875
    public static function get_number_of_users_tracking_overview()
1876
    {
1877
        $table = Database :: get_main_table(TABLE_MAIN_USER);
1878
        $sql = "SELECT COUNT(id) count FROM $table";
1879
        $result = Database::query($sql);
1880
        $row = Database::fetch_assoc($result);
1881
1882
        return $row['count'];
1883
    }
1884
1885
    /**
1886
     * get all the data for the sortable table of the reporting progress of all users and all the courses the user is subscribed to.
@@ 2560-2568 (lines=9) @@
2557
    /**
2558
     * @return int
2559
     */
2560
    public static function getNumberOfTrackAccessOverview()
2561
    {
2562
        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
2563
        $sql = "SELECT COUNT(course_access_id) count FROM $table";
2564
        $result = Database::query($sql);
2565
        $row = Database::fetch_assoc($result);
2566
2567
        return $row['count'];
2568
    }
2569
2570
    /**
2571
     * @param $from

main/inc/lib/sessionmanager.lib.php 1 location

@@ 1181-1189 (lines=9) @@
1178
    /**
1179
     * @return int
1180
     */
1181
    public static function get_number_of_tracking_access_overview()
1182
    {
1183
        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1184
        $sql = "SELECT COUNT(course_access_id) count FROM $table";
1185
        $result = Database::query($sql);
1186
        $row = Database::fetch_assoc($result);
1187
1188
        return $row['count'];
1189
    }
1190
1191
    /**
1192
     * Get the ip, total of clicks, login date and time logged in for all user, in one session

main/inc/lib/course.lib.php 1 location

@@ 3094-3100 (lines=7) @@
3091
     * @param string Category code
3092
     * @return array Course category
3093
     */
3094
    public static function get_course_category($code)
3095
    {
3096
        $table_categories = Database::get_main_table(TABLE_MAIN_CATEGORY);
3097
        $code = Database::escape_string($code);
3098
        $sql = "SELECT * FROM $table_categories WHERE code = '$code'";
3099
        return Database::fetch_array(Database::query($sql));
3100
    }
3101
3102
    /**
3103
     * Returns the details of a course category

main/admin/settings.lib.php 1 location

@@ 941-953 (lines=13) @@
938
 * @version August 2008
939
 * @since v1.8.6
940
 */
941
function getNumberOfTemplates()
942
{
943
    // Database table definition.
944
    $table_system_template = Database :: get_main_table('system_template');
945
946
    // The sql statement.
947
    $sql = "SELECT COUNT(id) AS total FROM $table_system_template";
948
    $result = Database::query($sql);
949
    $row = Database::fetch_array($result);
950
951
    // Returning the number of templates.
952
    return $row['total'];
953
}
954
955
/**
956
 * Gets all the template data for the sortable table.