You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The repository layer is classes that have functions to access the database, for example, insert,update, etc.
134
140
135
-
We want to create it automatically as follow.
141
+
The library PdoOne allows to create the repository layer using the database.
136
142
137
143
Let's create this PHP file (in the root of the project)
138
144
139
-
```
145
+
📄/genrepo.php
146
+
147
+
```php
140
148
<?php
141
149
142
150
use eftec\PdoOne;
@@ -152,7 +160,7 @@ where 127.0.0.1 is the server, root = user, abc.123 = password and example_edita
152
160
153
161
**loglevel**=3 is if something goes south then it will show the error.
154
162
155
-
And renders shows the next screen:
163
+
And renders shows the next screen: (open the page to show this page)
156
164
157
165

158
166
@@ -162,7 +170,7 @@ Add the next information. Where it says "**input**", select the name of the tab
162
170
163
171
For output, selects the option "**classcode**". It will generate our class.
164
172
165
-
Press generate and copy the result (is in **log**)
173
+
Press generate and copy the result (is generated in **log** text area)
166
174
167
175
It will generate the next code
168
176
@@ -186,6 +194,10 @@ Copy this code and save in a folder (in my case I will use the folder **repo**)
186
194
187
195
Repeats the same procedure with all the tables.
188
196
197
+
📄 repo/CountryRepo.php
198
+
199
+
📄 repo/PlayersRepo.php
200
+
189
201
## 5 Views
190
202
191
203
In the folder views, create the next file 📄 views/table.blade.php
@@ -302,9 +314,7 @@ echo $blade->run('table',[]);
302
314
303
315
:-|
304
316
305
-

306
-
307
-
Ok, it is a start but it misses the web services mentioned in the step 5.
317
+
Ok, it is a start but it misses the web services mentioned in the step 5.
308
318
309
319
## 8 Creating web service.
310
320
@@ -434,10 +444,10 @@ Listing the countries. We use the class **CountryRepo**. We could also sort, pag
434
444
$result = CountryRepo::toList(); // select * from country
435
445
```
436
446
437
-
Listing the players. We need a custom query so we create directly (without the Repository layer). It is because we need all the columns of players but also the name of the country.
447
+
Listing the players. We need a custom query so we create it directly (without the Repository class). It is because we need all the columns of players but also the name of the country.
438
448
439
449
```php
440
-
$r['records'] = $pdoOne->select('ID,Players.Name,Country.Name as CountryName,IsActive')->from('Players')
450
+
$r['records'] = $pdoOne->select('ID,Players.Name,Country.Name as CountryName,IsActive')->from('Players')
441
451
->left('Country on Players.IdCounty=Country.IdCounty')->toList();
442
452
```
443
453
### 8.4 Update and delete
@@ -456,3 +466,6 @@ Execute the same page than step 7 and it is the final result. If something fails
0 commit comments