-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImplementModel.php
More file actions
92 lines (75 loc) · 2.44 KB
/
Copy pathImplementModel.php
File metadata and controls
92 lines (75 loc) · 2.44 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
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
92
<?php
declare(strict_types=1);
namespace tests;
use Rancoud\Model\Field;
use Rancoud\Model\FieldException;
use Rancoud\Model\Model;
use Rancoud\Model\ModelException;
/**
* @internal
*/
class ImplementModel extends Model
{
protected array $parametersToRemove = ['param_to_remove'];
protected bool $isHackWrong = false;
public function __construct($database)
{
parent::__construct($database);
}
/** @throws FieldException */
protected function setFields(): void
{
$this->fields = [
'id' => new Field('int', ['pk', 'unsigned', 'not_null']),
'title' => new Field('varchar', ['max:5']),
'date_start' => new Field('datetime', ['not_null']),
'year_start' => new Field('year', []),
'hour_start' => new Field('time', [], '00:00:00'),
'hour_stop' => new Field('time', [], null),
'is_visible' => new Field('enum:yes,no', ['not_null'], 'yes'),
'email' => new Field('varchar', ['email']),
'nomaxlimit' => new Field('varchar', ['max:']),
'external_id' => new Field('int', ['fk', 'unsigned'])
];
}
protected function setTable(): void
{
$this->table = 'crud_table';
}
public function setHackWrongGetSqlAllWhereAndFillSqlParams(bool $bool): void
{
$this->isHackWrong = $bool;
}
protected function getSqlAllWhereAndFillSqlParams(array $params): string
{
return ($this->isHackWrong) ? 'AND' : parent::getSqlAllWhereAndFillSqlParams($params);
}
public function removePkFields(): void
{
\array_shift($this->fields);
}
/** @throws FieldException */
public function setWrongPk(): void
{
$this->fields['wrong_id'] = new Field('int', ['pk', 'unsigned', 'not_null']);
}
/** @throws ModelException */
public function hackCreateSqlFieldsFromParams(): string
{
$this->sqlParams = ['invalid', 'key' => 'value'];
return $this->getCreateSqlFieldsFromParams();
}
/** @throws ModelException */
public function hackUpdateSqlFieldsFromParams(): string
{
$this->sqlParams = ['invalid', 'key' => 'value'];
return $this->getUpdateSqlFieldsFromParams();
}
/** @throws FieldException */
public function usePostgresql(): void
{
$this->fields = [
'date_start' => new Field('timestamp', ['not_null'])
];
}
}