-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
91 lines (80 loc) · 2.28 KB
/
test.php
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
use Nebula\Helpers\MySQL;
use Nebula\Helpers\Template;
use Nebula\Helpers\Validate;
define('NEBULA_ROOT_PATH', __DIR__ . '/');
include __DIR__ . '/includes/Common.php';
// $mysql = MySQL::getInstance();
// $mysql->init([
// 'dbname' => 'nebula',
// 'host' => 'localhost',
// 'port' => '3306',
// 'username' => 'root',
// 'password' => 'root',
// 'prefix' => 'nebula_',
// ]);
// $result = $mysql->select('users', ['password'])->where([
// 'OR' => [
// 'uid' => 1,
// 'email' => 1,
// ]
// ])->execute();
// 创建配置表
// $mysql->create('options', [
// 'name' => ['VARCHAR(30)', 'NOT NULL', 'PRIMARY KEY'],
// 'value' => ['LONGTEXT', 'NOT NULL'],
// ]);
// // 插入配置数据
// $result = $mysql
// ->update("options", ['value' => '222'])
// ->where(['name' => 'theme'])
// ->execute();
// $result = $mysql->delete('users', ['username'])
// ->where([
// 'usern1ame' => 'admi1n'
// ])->execute();
// echo "<pre>";
// $res = $mysql->has('users')->execute();
class Test
{
public function check($value, $callable)
{
echo $value;
$callable('你好');
}
public function a()
{
$data = [
'username' => '1',
'email' => '[email protected]',
'password' => '123456789',
'password1' => '1234567819',
];
$validate = new Validate($data, [
'username' => [
['type' => 'required', 'message' => '用户名不能为空'],
],
'email' => [
['type' => 'required', 'message' => '邮箱不能为空'],
['type' => 'email', 'message' => '邮箱格式不正确'],
],
'password' => [],
'password1' => [
[
'type' => 'custom',
'validator' => function ($rule, $value, $callback) use ($data) {
if ($data['password'] !== $value) {
$callback('两次输入密码不一致');
}
},
]
],
]);
if (!$validate->run()) {
print_r($validate->result[0]['message']);
} else {
echo '成功';
}
}
}
(new Test())->a();