![Codeigniter 4🔥 [14.- model,allowedFields,Querybuilder,asArray,asObject,beforeInsert,beforeUpdate] 1 codeigniter 14](https://www.programadornovato.com/wp-content/uploads/2020/05/codeigniter-14-535x251.jpg)
Codeigniter 4🔥 [14.- model,allowedFields,Querybuilder,asArray,asObject,beforeInsert,beforeUpdate]
En este tutorial vamos a trabajar con algunas funciones extra que nos entrega codeigniter 4 que son estas: Proteccion de campos (allowedFields) Querybuilder Cambiar los tipos de retornos de codeigniter 4 (asArray y asObject). Eventos (beforeInsert y beforeUpdate)
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/
Muy bien artículo, me hizo aprender a como sacar el promedio de notas.