From 301c591e6fc7334f13802a2efeae7704c81ddb79 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Tue, 13 Apr 2021 20:06:15 -0400 Subject: [PATCH] New translations db-models-relationships.md (Spanish) (#2846) --- es-es/db-models-relationships.md | 92 ++++++++++++++++---------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/es-es/db-models-relationships.md b/es-es/db-models-relationships.md index cf269d0ea566..c8bcb22467cc 100644 --- a/es-es/db-models-relationships.md +++ b/es-es/db-models-relationships.md @@ -319,7 +319,7 @@ Dependiendo de las necesidades de nuestra aplicación podríamos querer almacena Usando las relaciones, puede obtener únicamente aquellos `Customers` relacionados con nuestras `Invoices` que tienen un `cst_status_flag` determinado. Definir esa restricción en la relación le permite dejar que el modelo haga todo el trabajo. -It also accepts a closure, which is evaluated every time before the related records are accessed. This enables the conditions to be automatically updated between queries. +También acepta una clausura, que es evaluada cada vez antes de acceder a registros relacionados. Esto permite que las condiciones se actualicen automáticamente entre las consultas. ```php invoices as $invoice) { } ``` -or for a many to many relationship (see models above): +o para una relación muchos a muchos (ver modelos anteriores): ```php products as $product) { } ``` -Using the magic `__get` allows you to access the relationship directly but does not offer additional functionality such as filtering or ordering on the relationship. +Usar el método mágico `__get` le permite acceder a la relación directamente pero no ofrece funcionalidad adicional como filtrado u ordenación sobre la relación. ### `get*()` -You can access the same relationship by using a getter method, starting with *get* and using the name of the relationship. +Puede acceder a la misma relación usando un método *getter*, que empieza con *get* y usa el nombre de la relación. ```php getInvoices() as $invoice) { } ``` -or for a many to many relationship (see models above): +o para una relación muchos a muchos (ver modelos anteriores): ```php getProducts() as $product) { } ``` -This magic getter also allows us to perform certain operations when accessing the relationship such as ordering the relationship: +Este *getter* mágico también nos permite ejecutar ciertas operaciones cuando se accede a la relación como ordenar la relación: ```php countProducts(); ### `getRelated()` -You can access the same relationship by using `getRelated()` and defining which relationship you want to get. +Puede acceder a la misma relación usando `getRelated()` y definir qué relación quiere obtener. ```php getRelated('invoices') as $invoice) { } ``` -or for a many to many relationship (see models above): +o para una relación muchos a muchos (ver modelos anteriores): ```php getRelated('products') as $product) { } ``` -The second parameter of `getRelated()` is an array that offers additional options to be set such as filtering and ordering. +El segundo parámetro de `getRelated()` es un vector que ofrece opciones adicionales a configurar, como filtrar u ordenar. ```php **NOTA**: Se recomienda usar la opción `reusable` tan a menudo como sea posible en sus relaciones {: .alert .alert-info } @@ -916,7 +916,7 @@ class Invoices extends Model ## Autocompletado -Most IDEs and editors with auto-completion capabilities can not detect the correct types when using magic getters (both methods and properties). To address this issue, you can use the class docblock that specifies what magic actions are available, helping the IDE to produce a better auto-completion: +La mayoría de IDEs y editores con capacidades de autocompletado puede que no detecten los tipos correctos cuando se usan *getters* mágicos (tanto métodos como propiedades). Para abordar este problema, podemos usar la clase docblock que especifica qué acciones mágicas están disponibles, ayudando al IDE a producir un mejor autocompletado: ```php getRelated( ## Claves Ajenas Virtuales -By default, relationships do not have any constraints attached to them, to check related data when adding, updating or deleting records. You can however attach validations to your relationships, to ensure integrity of data. This can be done with the last parameter of the relationship related method. +Por defecto, las relaciones no tienen ninguna restricción adjunta a ellas, para comprobar datos relacionados cuando se añaden, actualizan o borran registros. Sin embargo, puede adjuntar validaciones a sus relaciones, para asegurar la integridad de los datos. Esto se puede hacer con el último parámetro del método relacionado con la relación. -The cross table `InvoicesProducts` can be slightly changed to demonstrate this functionality: +La tabla de cruce `InvoicesProducts` se puede cambiar ligeramente para demostrar esta funcionalidad: ```php year = 2008; $album->save(); ``` -Saving a record and its related records in a has-many relation: +Guardando un registro y sus registros relacionados en una relación *has-many*: ```php invoices = [ $customer->save(); ``` -The code above gets a customer from our database. Two invoices are created and assigned to the `invoices` relationship of the customer as an array. The customer record is then saved, which also saves the two invoices in the database and links them to the customer. +El código anterior obtiene un cliente de nuestra base de datos. Se crean dos facturas y se asignan a la relación `invoices` del cliente como un vector. Se guarda entonces el registro de cliente, lo que también guarda las dos facturas en la base de datos y las enlaza al cliente. -Although the syntax above is very handy, it is not always ideal to use it, especially when updating related records. Phalcon does not know which records need to be added or removed using an **update**, and as a result it will perform a replace. In update situations, it is better to control the data yourself vs. leaving it to the framework to do that. +Aunque la sintaxis anterior es muy útil, no siempre es ideal para usar, especialmente cuando actualiza registros relacionados. Phalcon no sabe qué registros necesitan ser añadidos o eliminados usando un **update**, y como resultado ejecutará un *replace*. En situaciones de actualización, es mejor controlar los datos por si mismo vs. dejar que lo haga el framework. -Saving data with the above syntax will implicitly create a transaction and commit it if all goes well. Messages generated during the save process of the whole transaction will be passed back to the user for more information. +Guardar los datos con la sintaxis anterior implícitamente creará una transacción y la confirmará si todo va bien. Los mensajes generados durante el proceso de guardado de toda la transacción se devolverán al usuario para más información. > **NOTA**: Añadir entidades relacionadas por sobrecarga de los siguientes métodos/eventos **no** es possible: > @@ -1320,11 +1320,11 @@ Saving data with the above syntax will implicitly create a transaction and commi > - `Phalcon\Mvc\Model::beforeUpdate()` {: .alert .alert-warning } -You need to overload `Phalcon\Mvc\Model::save()` for this to work from within a model. +Necesita sobrecargar `Phalcon\Mvc\Model::save()` para que esto funcione desde dentro de un modelo. ### Actualizar -Instead of doing this: +En lugar de hacer esto: ```php getInvoices()->update( ); ``` -`update` also accepts an anonymous function to filter what records must be updated: +`update` también acepta una función anónima para filtrar los registros que se deben actualizar: ```php getInvoices()->update( ### Eliminar -Instead of doing this: +En lugar de hacer esto: ```php getInvoices()->delete(); ``` -`delete()` also accepts an anonymous function to filter what records must be deleted: +`delete()` también acepta una función anónima para filtrar los registros que se deben eliminar: ```php