| Ambdós costats versió prèvia Revisió prèvia Següent revisió | Revisió prèvia |
| development:php:codeigniter:v4:model [08/06/2026 00:56] – [in-Model Validation] mate | development:php:codeigniter:v4:model [08/06/2026 01:31] (actual) – [placeholders] mate |
|---|
| * ''$beforeInsert = [];'' | * ''$beforeInsert = [];'' |
| * ''$afterInsert = [];'' | * ''$afterInsert = [];'' |
| | * ''$beforeInsertBatch = [];'' |
| | * ''$afterInsertBatch = [];'' |
| * ''$beforeUpdate = [];'' | * ''$beforeUpdate = [];'' |
| * ''$afterUpdate = [];'' | * ''$afterUpdate = [];'' |
| | * ''$beforeUpdateBatch = [];'' |
| | * ''$afterUpdateBatch = [];'' |
| * ''$beforeFind = [];'' | * ''$beforeFind = [];'' |
| * ''$afterFind = [];'' | * ''$afterFind = [];'' |
| * ''first()'': solo retorna el primer registro | * ''first()'': solo retorna el primer registro |
| * ''withDeleted()'' | * ''withDeleted()'' |
| | * ''asArray()'' ''asObject()'' <- Entity |
| * ''insert($data[,$bool])'' | * ''insert($data[,$bool])'' |
| * $data: array de valores de campos | * $data: array de valores de campos |
| * con ''$useSoftDeletes=true'', se actualiza la columna indicada en ''$deletedField'' | * con ''$useSoftDeletes=true'', se actualiza la columna indicada en ''$deletedField'' |
| * ''purgeDeleted()'' | * ''purgeDeleted()'' |
| | * ''chunk()'': para procesar un gran volumen de datos de manera fraccionada |
| |
| == in-Model Validation | == in-Model Validation |
| * también se puede indicar un grupo de reglas de validaciones [[https://codeigniter.com/user_guide/libraries/validation.html#saving-validation-rules-to-config-file]] | * también se puede indicar un grupo de reglas de validaciones [[https://codeigniter.com/user_guide/libraries/validation.html#saving-validation-rules-to-config-file]] |
| === placeholders | === placeholders |
| | * [[https://codeigniter.com/user_guide/libraries/validation.html#rules-for-general-use]] |
| * [[https://codeigniter.com/user_guide/libraries/validation.html#validation-available-rules]] | * [[https://codeigniter.com/user_guide/libraries/validation.html#validation-available-rules]] |
| * ''is_unique'' | * ''is_unique'' |
| * ''is_unique[tabla.campo,id,{id}'' único campo para el id={id} (si es el campo $primaryKey) | * ''is_unique[tabla.campo,id,{id}'' único campo para el id={id} (si es el campo $primaryKey) |
| | * ''alpha*'', ''string'' |
| | * ''field_exists'' |
| | * ''in_list'', ''not_in_list'' |
| | * ''max_length'', ''min_length'', ''exact_length'' |
| | * ''permit_empty'' |
| | * ''required'',''required_with'',''required_without'' |
| | * ''valid_email'',''valid_emails'' |
| | * ''valid_date'' |
| | * ''valid_json'' |
| == protecting Fields | == protecting Fields |
| * ''$allowedFields'' | * ''$allowedFields'' |
| * ''protect(true|false)'' | * ''protect(true|false)'' |
| | |
| | == Callbacks |
| | * [[https://codeigniter.com/user_guide/models/model.html#defining-callbacks]] |
| | * ''allowCallbacks(false)'' |
| == crear | == crear |
| <code php> | <code php> |