1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DBStatic; |
4
|
|
|
use classSupernova; |
5
|
|
|
use mysqli_result; |
6
|
|
|
use template; |
7
|
|
|
|
8
|
|
|
class DBStaticNews { |
9
|
|
|
|
10
|
|
|
public static function db_news_update_set($announce_time, $text_unsafe, $detail_url_unsafe, $announce_id) { |
11
|
|
|
classSupernova::$db->doUpdateRowSet( |
12
|
|
|
TABLE_ANNOUNCE, |
13
|
|
|
array( |
14
|
|
|
'tsTimeStamp' => date(FMT_DATE_TIME_SQL, $announce_time), |
15
|
|
|
'strAnnounce' => $text_unsafe, |
16
|
|
|
'detail_url' => $detail_url_unsafe, |
17
|
|
|
), |
18
|
|
|
array( |
19
|
|
|
'idAnnounce' => $announce_id, |
20
|
|
|
) |
21
|
|
|
); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public static function db_news_insert_set($announce_time, $text_unsafe, $detail_url_unsafe, $userId, $userNameUnsafe) { |
25
|
|
|
classSupernova::$db->doInsertSet(TABLE_ANNOUNCE, array( |
26
|
|
|
'tsTimeStamp' => date(FMT_DATE_TIME_SQL, $announce_time), |
27
|
|
|
'strAnnounce' => $text_unsafe, |
28
|
|
|
'detail_url' => $detail_url_unsafe, |
29
|
|
|
'user_id' => $userId, |
30
|
|
|
'user_name' => $userNameUnsafe, |
31
|
|
|
)); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public static function db_news_delete_by_id($announce_id) { |
35
|
|
|
classSupernova::$gc->db->doDeleteRow( |
|
|
|
|
36
|
|
|
TABLE_ANNOUNCE, |
37
|
|
|
array( |
38
|
|
|
'idAnnounce' => $announce_id, |
39
|
|
|
) |
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public static function db_news_with_survey_select_by_id($announce_id) { |
44
|
|
|
return classSupernova::$db->doSelectFetch( |
45
|
|
|
"SELECT a.*, s.survey_id, s.survey_question, s.survey_until |
46
|
|
|
FROM {{announce}} AS a |
47
|
|
|
LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce |
48
|
|
|
WHERE `idAnnounce` = {$announce_id} LIMIT 1;"); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param template $template |
53
|
|
|
* @param $query_where |
54
|
|
|
* @param $query_limit |
55
|
|
|
* |
56
|
|
|
* @return array|bool|mysqli_result|null |
57
|
|
|
*/ |
58
|
|
|
public static function db_news_list_get_by_query(&$template, $query_where, $query_limit) { |
59
|
|
|
$announce_list = classSupernova::$db->doSelect( |
60
|
|
|
"SELECT a.*, UNIX_TIMESTAMP(`tsTimeStamp`) AS unix_time, u.authlevel, s.* |
61
|
|
|
FROM |
62
|
|
|
{{announce}} AS a |
63
|
|
|
LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce |
64
|
|
|
LEFT JOIN {{users}} AS u ON u.id = a.user_id |
65
|
|
|
{$query_where} |
66
|
|
|
ORDER BY `tsTimeStamp` DESC, idAnnounce" . |
67
|
|
|
($query_limit ? " LIMIT {$query_limit}" : '')); |
68
|
|
|
|
69
|
|
|
$template->assign_var('NEWS_COUNT', classSupernova::$db->db_num_rows($announce_list)); |
70
|
|
|
|
71
|
|
|
return $announce_list; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: