Answer the question
In order to leave comments, you need to log in
How to simplify the given RedBeanPHP code?
This code takes data from the form and saves it to the database through a bean in RedBeanPHP. The input names match the bean elements (and hence the fields in the database table).
$GLOBALS['employee']->first_name = $_POST['main']['first_name'];
$GLOBALS['employee']->last_name = $_POST['main']['last_name'];
$GLOBALS['employee']->patronymic = $_POST['main']['patronymic'];
R::store( $GLOBALS['employee']);
Answer the question
In order to leave comments, you need to log in
You create an entity, write all the properties in it by the names of the table fields, create a magic setter, accept the post array, run through the loop, get the data that came in, set it, save it. Of course, between all this you do checks for null.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question