Hello and welcome to the golden programming language course in the previous session.
We could create a select function that fits all members of a student table in person database.
And in this case, we want to create a function to update a student in a student table in person database.
We want to do the opposite operation in two ways.
First, for update a student or a record of a student data.
And second for update more than a student record or many records in a student table.
First, we want to talk about update.
Students now go to DB connection fine.
First, define the function name single update form.
Single update this function accept two parameters.
First parameter is an AMD interface, which indicates that an instance of a strike is to be passed to
this method.
And second parameter is a map, which the update information is sent to the middle.
Also, this function returns the number of records that have been affected by the update operation at
the end of the watch.
So first set in name like object by the time and to interface, object and and interface set to come
on and sit a name like data for define and map data not set by the time jetstream.
And Sith value by the time empty in their face, because we don't know what time of the value was sent
to the function into interface and set N64 as a return type.
Now, Colin Connect function for initializing MySchool School DataSource name, this function returns
a DB object from goram packets, so define a variable like DB calling equals and calling conic function
after creating a DB object from quorum packets being what finite function?
This function acts as student instance, then running set query on the student table and fetching a
student from database and return it.
So the right DB don't find and sit object and argument.
Then declining model function from the object and Sith object instance as arguments for it before calling
it first define a variable like reason for the return type model function is specify the model you would
like to run operations, so be right.
Result calling equals and calling model function on DB object DB thought model and set object as argument
and more.
Invoke this function instead.
Data object as a map argument for it.
Updates function update attributes with callbacks, dot off days
and set data has argued date.
Now, invoking Groves affected field from resolved to return that we should update the fact that records
sold the right, Rita resolved that those affected OK, reformat the court and save the project.
We have now succeeded in designing a method to receive a strike instance from the outside and update
the values of descent object.
According to the values given the other maps sent now, go to the main function to use this query statement
first to your last court.
In this case, we want to opt it in new student in person database, so we should use from single update
function from DB tools.
Suppose a student with I.D. number one is the database and we want to change the name and age values
of it.
So create an a student object from a student district and initialize I.D. value in it.
A student calling equals model dot student and initialize I.D.
equals one and now define the map variable for send new data.
After opting for this instead.
So vraie data column equals map.
The time off key is estrange and the type of value is empty.
Interface.
Name
equals.
John?
And H equals forty.
Now calling update function from DevTools package and sent created a student object as first argument
and data.
A second argument to eat and fish row affected.
So first define a variable like row
column equals DevTools Dot single object and sit ampersand the student.
And said they'd.
And now display return time as roll variable.
So we write FP
roles affected and set variable low.
Before run the program, go to the database and see the values of name and age of ID number one.
We can see the ID number one name is changed and ages 20.
Go to the village school program and run the project go wrong.
Dot packets Maine and Maine dot gov.
Now we can see the output rose effect, it is one now go to the database again and executed select query
and see the changes.
OK, now we can see name and age of ex-student object is object correctly in the person database and
one row is affected, i.e. the one name has changed to John and age has changed to 40 in order not to
prolong the time of decision.
We will finish, then we will continue the content in the next session.
Goodbye.