Codeigniter 4🔥 [10.- model,find,findAll,withDeleted,onlyDeleted]
- En este tutorial vamos a seguir trabajando con modelos de codeigniter 4 y en particular vamos usar esta funciones de búsqueda:
- find
- findAll
- where
- withDeleted
- onlyDeleted
Codigo en github.com: https://github.com/programadornovato/codeigniter4/commit/806620237c14a60ccb039eed10ebbbc13a22b749
//app/Controllers/Home.php <?php namespace App\Controllers; use CodeIgniter\Controller; use App\Models\UserModel; class Home extends BaseController { public function index() { $userModel=new UserModel($db); //$users=$userModel->find([1,2]); //$users=$userModel->findAll(); //$users=$userModel->where('name','maria')->findAll(); //$users=$userModel->findAll(2,3); //$users=$userModel->withDeleted()->findAll(); $users=$userModel->onlyDeleted()->findAll(); $users=array('users'=>$users); $estructura=view('estructura/header').view('estructura/body',$users); return $estructura; } //-------------------------------------------------------------------- } //app/Views/estructura/body.php <body> <table> <tr> <th>name</th> <th>email</th> <th>deleted</th> </tr> <?php foreach($users as $user){ echo "<tr>"; echo "<td>".$user['name']."</td>"; echo "<td>".$user['email']."</td>"; echo "<td>".$user['deleted']."</td>"; echo "</tr>"; } ?> </table> </body> </html>
#Codeigniter4 #php7 #backend #Codeigniter #php .
? Esta lista de reproducción: https://www.youtube.com/playlist?list=PLCTD_CpMeEKTFN5TDeOP-wP_hU0_9VoWg
.
Codigos en gdrive: https://drive.google.com/file/d/1awbG6jI40IO0N68fgjLUwNFpsTC3wIHj/view?usp=sharing .
Gracias por apoyar este canal: https://www.patreon.com/programadornovato?fan_landing=true .
? Facebook: https://facebook.com/ProgramadorNovatoOficial
? Twitter: https://twitter.com/programadornova
? Linkedin: https://www.linkedin.com/in/programadornovato/
? Instagram: https://www.instagram.com/programadornovato/