obsidian/MyObsidianVault/WebDev/2 CodeIgniter/04.) Model based query methods.md

37 lines
674 B
Markdown
Raw Normal View History

2024-11-13 09:05:39 +01:00
https://www.youtube.com/watch?v=4_MdtVqfH1o&list=PLT9miexWCpPW6Z_OXNv2d78cqCrZaPrVG&index=9
```bash
php spark make:model Student --suffix
```
Creates StudentModel.php in app/Models
Add allowedFields
![[Pasted image 20241113082554.png]]
Add Model to Controller
![[Pasted image 20241113082703.png]]
![[Pasted image 20241113083139.png]]
add to routes
```php
$routes->get("add-student", "StudentController::insertStudent");
```
update example (condition, data):
![[Pasted image 20241113083603.png]]
delete:
![[Pasted image 20241113083823.png]]
get all :
![[Pasted image 20241113084056.png]]
get single with generic condition:
![[Pasted image 20241113084645.png]]