-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelper.php
More file actions
53 lines (53 loc) · 1.26 KB
/
Copy pathhelper.php
File metadata and controls
53 lines (53 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?
class helper
{
public static function getConnection()
{
$paramsPath = ROOT.'/db_params.php';
$params = include($paramsPath);
$mysqli = new mysqli($params['host'], $params['login'], $params['password'], $params['db']);
return $mysqli;
}
public static function validateEmail($email)
{
return preg_match("/^(\S+)@([a-z0-9-]+)(\.)([a-z]{2,4})(\.?)([a-z]{0,4})+$/",$email);
}
public static function validateText($text)
{
return strlen($text)>=20?1:0;
}
public static function selectData()
{
$mysqli = helper::getConnection();
$res = $mysqli->query("SELECT * FROM `htmlform`");
$rows = array();
while($row = $res->fetch_array())
{
$rows[] = $row;
}
return $rows;
}
public static function sortDesc()
{
$mysqli = helper::getConnection();
$res = $mysqli->query("SELECT * FROM `htmlform` ORDER BY `htmlform`.`DATE` DESC");
$rows = array();
while($row = $res->fetch_array())
{
$rows[] = $row;
}
return $rows;
}
public static function sortAsc()
{
$mysqli = helper::getConnection();
$res = $mysqli->query("SELECT * FROM `htmlform` ORDER BY `htmlform`.`DATE` ASC");
$rows = array();
while($row = $res->fetch_array())
{
$rows[] = $row;
}
return $rows;
}
}
?>