|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DebugsTests; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use CommonTestClass; |
|
7
|
|
|
use kalanis\kw_mapper\Interfaces\IEntryType; |
|
8
|
|
|
use kalanis\kw_mapper\MapperException; |
|
9
|
|
|
use kalanis\kw_mapper\Mappers; |
|
10
|
|
|
use kalanis\kw_mapper\Records; |
|
11
|
|
|
use kalanis\kw_mapper\Search; |
|
12
|
|
|
use kalanis\kw_mapper\Storage; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
class DebugTest extends CommonTestClass |
|
16
|
|
|
{ |
|
17
|
|
|
public function testContentOk(): void |
|
18
|
|
|
{ |
|
19
|
|
|
// $record = new PedigreeRecord(); |
|
20
|
|
|
// $record->kennel = 'von Arlett'; |
|
21
|
|
|
// $record->load(); |
|
22
|
|
|
//var_dump($record); |
|
23
|
|
|
|
|
24
|
|
|
// $record = new PedigreeRecord(); |
|
25
|
|
|
// $record->kennel = 'Z GILANU'; |
|
26
|
|
|
//var_dump(['gl', $record->loadMultiple()]); |
|
27
|
|
|
|
|
28
|
|
|
// $search = new Search\Search(new PedigreeRecord()); |
|
29
|
|
|
// $search->like('kennel', '%GILAN%'); |
|
30
|
|
|
//// $search->offset(3); |
|
31
|
|
|
//// $search->limit(6); |
|
32
|
|
|
// $search->limit(2); |
|
33
|
|
|
////var_dump(['cnt', $search->getCount()]); |
|
34
|
|
|
//var_dump(['all', $search->getResults()]); |
|
35
|
|
|
|
|
36
|
|
|
try { |
|
37
|
|
|
$search = new Search\Search(new PedigreeUpdateRecord()); |
|
38
|
|
|
// $search->like('kennel', '%GILAN%'); |
|
39
|
|
|
// $search->child('parents', '', '', 'par'); |
|
40
|
|
|
$search->child('children'); |
|
41
|
|
|
$search->child('sires', '', 'children', 'chil'); |
|
42
|
|
|
$search->like('chil.kennel', '%GILAN%'); |
|
43
|
|
|
// $search->offset(3); |
|
44
|
|
|
// $search->limit(6); |
|
45
|
|
|
$search->limit(2); |
|
46
|
|
|
//var_dump(['cnt', $search->getCount()]); |
|
47
|
|
|
var_dump(['all', $search->getResults()]); |
|
48
|
|
|
//print_r(['all', $search->getResults()]); |
|
49
|
|
|
|
|
50
|
|
|
} catch (MapperException $ex) { |
|
51
|
|
|
$this->assertTrue(false, $ex->getMessage()); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$this->assertTrue(true); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Class PedigreeUpdateRecord |
|
61
|
|
|
* @property int id |
|
62
|
|
|
* @property string key |
|
63
|
|
|
* @property string name |
|
64
|
|
|
* @property string kennel |
|
65
|
|
|
* @property string birth |
|
66
|
|
|
* @property string address |
|
67
|
|
|
* @property string trials |
|
68
|
|
|
* @property string photo |
|
69
|
|
|
* @property int photoX |
|
70
|
|
|
* @property int photoY |
|
71
|
|
|
* @property string breed |
|
72
|
|
|
* @property string sex |
|
73
|
|
|
* @property string text |
|
74
|
|
|
* @property \DebugsTests\PedigreeRelateRecord[] parents |
|
75
|
|
|
* @property \DebugsTests\PedigreeRelateRecord[] children |
|
76
|
|
|
*/ |
|
77
|
|
|
class PedigreeUpdateRecord extends Records\AStrictRecord |
|
78
|
|
|
{ |
|
79
|
|
|
protected function addEntries(): void |
|
80
|
|
|
{ |
|
81
|
|
|
$this->addEntry('id', IEntryType::TYPE_INTEGER, 2048); |
|
82
|
|
|
$this->addEntry('key', IEntryType::TYPE_STRING, 50); |
|
83
|
|
|
$this->addEntry('name', IEntryType::TYPE_STRING, 75); |
|
84
|
|
|
$this->addEntry('kennel', IEntryType::TYPE_STRING, 255); |
|
85
|
|
|
$this->addEntry('birth', IEntryType::TYPE_STRING, 32); |
|
86
|
|
|
$this->addEntry('address', IEntryType::TYPE_STRING, 255); |
|
87
|
|
|
$this->addEntry('trials', IEntryType::TYPE_STRING, 255); |
|
88
|
|
|
$this->addEntry('photo', IEntryType::TYPE_STRING, 255); |
|
89
|
|
|
$this->addEntry('photoX', IEntryType::TYPE_INTEGER, 2048); |
|
90
|
|
|
$this->addEntry('photoY', IEntryType::TYPE_INTEGER, 2048); |
|
91
|
|
|
$this->addEntry('breed', IEntryType::TYPE_SET, ['no','yes','died']); |
|
92
|
|
|
$this->addEntry('sex', IEntryType::TYPE_SET, ['female','male']); |
|
93
|
|
|
$this->addEntry('blood', IEntryType::TYPE_SET, ['our','other']); |
|
94
|
|
|
$this->addEntry('text', IEntryType::TYPE_STRING, 8192); |
|
95
|
|
|
$this->addEntry('parents', IEntryType::TYPE_ARRAY); // FK - makes the array of entries every time |
|
96
|
|
|
$this->addEntry('children', IEntryType::TYPE_ARRAY); // FK - makes the array of entries every time |
|
97
|
|
|
$this->setMapper('\DebugsTests\PedigreeUpdateMapper'); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
class PedigreeUpdateMapper extends Mappers\Database\ADatabase |
|
103
|
|
|
{ |
|
104
|
|
|
protected function setMap(): void |
|
105
|
|
|
{ |
|
106
|
|
|
$this->setSource('devel'); |
|
107
|
|
|
$this->setTable('kal_pedigree_upd'); |
|
108
|
|
|
$this->setRelation('id', 'kp_id'); |
|
109
|
|
|
$this->setRelation('name', 'kp_name'); |
|
110
|
|
|
$this->setRelation('kennel', 'kp_kennel'); |
|
111
|
|
|
$this->setRelation('birth', 'kp_birth'); |
|
112
|
|
|
$this->setRelation('address', 'kp_address'); |
|
113
|
|
|
$this->setRelation('trials', 'kp_trials'); |
|
114
|
|
|
$this->setRelation('photo', 'kp_photo'); |
|
115
|
|
|
$this->setRelation('photoX', 'kp_photo_x'); |
|
116
|
|
|
$this->setRelation('photoY', 'kp_photo_y'); |
|
117
|
|
|
$this->setRelation('breed', 'kp_breed'); |
|
118
|
|
|
$this->setRelation('sex', 'kp_sex'); |
|
119
|
|
|
$this->setRelation('blood', 'kp_blood'); |
|
120
|
|
|
$this->setRelation('text', 'kp_text'); |
|
121
|
|
|
$this->addPrimaryKey('id'); |
|
122
|
|
|
$this->addForeignKey('parents', '\DebugsTests\PedigreeRelateRecord', 'id', 'childId'); |
|
123
|
|
|
$this->addForeignKey('children', '\DebugsTests\PedigreeRelateRecord', 'id', 'parentId'); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Class PedigreeRelateRecord |
|
130
|
|
|
* @property int id |
|
131
|
|
|
* @property int childId |
|
132
|
|
|
* @property int parentId |
|
133
|
|
|
* @property \DebugsTests\PedigreeUpdateRecord[] parents |
|
134
|
|
|
* @property \DebugsTests\PedigreeUpdateRecord[] children |
|
135
|
|
|
*/ |
|
136
|
|
|
class PedigreeRelateRecord extends Records\AStrictRecord |
|
137
|
|
|
{ |
|
138
|
|
|
protected function addEntries(): void |
|
139
|
|
|
{ |
|
140
|
|
|
$this->addEntry('id', IEntryType::TYPE_INTEGER, 2048); |
|
141
|
|
|
$this->addEntry('childId', IEntryType::TYPE_INTEGER, 2048); |
|
142
|
|
|
$this->addEntry('parentId', IEntryType::TYPE_INTEGER, 2048); |
|
143
|
|
|
$this->addEntry('oldes', IEntryType::TYPE_ARRAY); // FK - makes the array of entries every time |
|
144
|
|
|
$this->addEntry('sires', IEntryType::TYPE_ARRAY); // FK - makes the array of entries every time |
|
145
|
|
|
$this->setMapper('\DebugsTests\PedigreeRelateMapper'); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
|
|
150
|
|
|
class PedigreeRelateMapper extends Mappers\Database\ADatabase |
|
151
|
|
|
{ |
|
152
|
|
|
protected function setMap(): void |
|
153
|
|
|
{ |
|
154
|
|
|
$this->setSource('devel'); |
|
155
|
|
|
$this->setTable('kal_pedigree_relate'); |
|
156
|
|
|
$this->setRelation('id', 'kpr_id'); |
|
157
|
|
|
$this->setRelation('childId', 'kp_id_child'); |
|
158
|
|
|
$this->setRelation('parentId', 'kp_id_parent'); |
|
159
|
|
|
$this->addPrimaryKey('id'); |
|
160
|
|
|
$this->addForeignKey('oldes', '\DebugsTests\PedigreeUpdateRecord', 'parentId', 'id'); |
|
161
|
|
|
$this->addForeignKey('sires', '\DebugsTests\PedigreeUpdateRecord', 'childId', 'id'); |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Class PedigreeRecord |
|
168
|
|
|
* @property string id |
|
169
|
|
|
* @property string name |
|
170
|
|
|
* @property string kennel |
|
171
|
|
|
* @property string birth |
|
172
|
|
|
* @property string father |
|
173
|
|
|
* @property string mother |
|
174
|
|
|
* @property string fatherId |
|
175
|
|
|
* @property string motherId |
|
176
|
|
|
* @property string address |
|
177
|
|
|
* @property string trials |
|
178
|
|
|
* @property string photo |
|
179
|
|
|
* @property string photoX |
|
180
|
|
|
* @property string photoY |
|
181
|
|
|
* @property string breed |
|
182
|
|
|
* @property string sex |
|
183
|
|
|
* @property string text |
|
184
|
|
|
*/ |
|
185
|
|
|
class PedigreeRecord extends Records\AStrictRecord |
|
186
|
|
|
{ |
|
187
|
|
|
protected function addEntries(): void |
|
188
|
|
|
{ |
|
189
|
|
|
$this->addEntry('id', IEntryType::TYPE_STRING, 50); |
|
190
|
|
|
$this->addEntry('name', IEntryType::TYPE_STRING, 75); |
|
191
|
|
|
$this->addEntry('kennel', IEntryType::TYPE_STRING, 255); |
|
192
|
|
|
$this->addEntry('birth', IEntryType::TYPE_STRING, 32); |
|
193
|
|
|
$this->addEntry('father', IEntryType::TYPE_STRING, 75); |
|
194
|
|
|
$this->addEntry('mother', IEntryType::TYPE_STRING, 75); |
|
195
|
|
|
$this->addEntry('fatherId', IEntryType::TYPE_STRING, 50); |
|
196
|
|
|
$this->addEntry('motherId', IEntryType::TYPE_STRING, 50); |
|
197
|
|
|
$this->addEntry('address', IEntryType::TYPE_STRING, 255); |
|
198
|
|
|
$this->addEntry('trials', IEntryType::TYPE_STRING, 255); |
|
199
|
|
|
$this->addEntry('photo', IEntryType::TYPE_STRING, 255); |
|
200
|
|
|
$this->addEntry('photoX', IEntryType::TYPE_INTEGER, 2048); |
|
201
|
|
|
$this->addEntry('photoY', IEntryType::TYPE_INTEGER, 2048); |
|
202
|
|
|
$this->addEntry('breed', IEntryType::TYPE_SET, ['no','yes','died']); |
|
203
|
|
|
$this->addEntry('sex', IEntryType::TYPE_SET, ['female','male']); |
|
204
|
|
|
$this->addEntry('blood', IEntryType::TYPE_SET, ['our','other']); |
|
205
|
|
|
$this->addEntry('text', IEntryType::TYPE_STRING, 8192); |
|
206
|
|
|
$this->setMapper('\DebugsTests\PedigreeMapper'); |
|
207
|
|
|
} |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
|
|
211
|
|
|
class PedigreeMapper extends Mappers\Database\ADatabase |
|
212
|
|
|
{ |
|
213
|
|
|
protected function setMap(): void |
|
214
|
|
|
{ |
|
215
|
|
|
$this->setSource('devel'); |
|
216
|
|
|
$this->setTable('kal_pedigree'); |
|
217
|
|
|
$this->setRelation('id', 'id'); |
|
218
|
|
|
$this->setRelation('name', 'name'); |
|
219
|
|
|
$this->setRelation('kennel', 'kennel'); |
|
220
|
|
|
$this->setRelation('birth', 'birth'); |
|
221
|
|
|
$this->setRelation('father', 'father'); |
|
222
|
|
|
$this->setRelation('mother', 'mother'); |
|
223
|
|
|
$this->setRelation('fatherId', 'father_id'); |
|
224
|
|
|
$this->setRelation('motherId', 'mother_id'); |
|
225
|
|
|
$this->setRelation('address', 'address'); |
|
226
|
|
|
$this->setRelation('trials', 'trials'); |
|
227
|
|
|
$this->setRelation('photo', 'photo'); |
|
228
|
|
|
$this->setRelation('photoX', 'photo_x'); |
|
229
|
|
|
$this->setRelation('photoY', 'photo_y'); |
|
230
|
|
|
$this->setRelation('breed', 'breed'); |
|
231
|
|
|
$this->setRelation('sex', 'sex'); |
|
232
|
|
|
$this->setRelation('blood', 'blood'); |
|
233
|
|
|
$this->setRelation('text', 'text'); |
|
234
|
|
|
$this->addPrimaryKey('id'); |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
|