Welcome Guest, Not a member yet? Register   Sign In
Validation: in_db[table.field]
#1

Imagine that you have a list of fruits in your database and your users need to select their favorite fruits (but it must be a fruit that previously existed in the database) ...

Currently, to validate the entry, you must select all the fruits from your database, implode the results array and put it into the validation rule with something like this: 

Code:
in_list['. Implode (',', $ result). ']'

It would be amazing if you could validate it with something like this: 

Code:
in_db[fruits.id]

Where "fruits" is the name of the table and "id" is the name of the field.

In addition, the query for the second validation method would be faster than the first one because in the second case you can search for a primary or unique key, while in the first you must search for all the "fruits" in the database.


Note: I am aware that currently you can still validate the entry by looking for the primary key outside the validation rules ... but this is not fun if the idea of using the validation rules is to facilitate the lives of the programmers.
Reply


Messages In This Thread
Validation: in_db[table.field] - by thingNumber1 - 10-27-2019, 12:26 PM
RE: Validation: in_db[table.field] - by MGatner - 11-01-2019, 05:55 AM
Solución - by thingNumber1 - 11-08-2019, 03:07 PM
RE: Validation: in_db[table.field] - by Ale - 01-20-2020, 03:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB