Hello and welcome to the golden programming language course in this session.
We want to create another function to update student in student table in person database.
So go to the TV connection, find and created our new function.
First, define it function named update that accept student object as parameter and returns the number
of rows affected.
So we write phone update set a parameter as a student by the time the student of modern.
And return times and 64 value
next calling clinic function for initializing my screwdriver name and data source name.
First, define a variable like call calling equals and calling conic function.
Use D3 for closing.
Create a TV object, the Ether TV dot close.
After creating a DV object from a school package, the Invoke prepper method that creates a prepared
statement for later callers or executioner's multiple queries or executions may be run concurrently
from the return to the statement.
This function returns to values.
First isn't the object from a school package that is a prepared statement, and the order is erotic.
So first, define two variables like object and or update comma.
Column equals and calling prepar function on the object DB to prepare now, write suitable query for
object and object.
So we write update.
A student.
Said name.
Equals instead of value, we said question mark and age equals sit and other question marks instead
of value for age and set virtual laws as condition where I.D. equals and sit and other question mark.
Okay.
Go to the next line and check a status if there are a lot of that error that they are
now cutting exec method from a school package and executes a prepared statement with the given arguments
and returns a result summarizing the effect of this statement.
This method returns to value first and object of result interface, and the other is and a raw object
so defined to Abi's life result and error result, comma error column equals and column exit function
on the update object update dot exec.
And so the student fills as parameter instead question marks in further statements sequentially.
First, the student may.
Second, a student at age.
And sit a student IDs condition for their clothes.
Student got I.D..
Now, take Aurora status.
Now, cutting roads affect effective function from a school package that returns the number of roads
affected by an update, insert or delete.
Not every database or database driver may support this.
This function returns to values first in 1864, when you and the other is, aren't there?
Or so we write two variables like roads affected and it all roads affected.
Comma L equals resolved dirt roads affected.
Go to the next line and check error status.
And return roads affected as return value later.
No.
But that reform of the court and say the project now, we could define the function name update that
accepted a student object as parameter and object that we call into the student table in person database
and returns the roles affected?
No.
Before we move on to go to the main function, we go to the MySchool database and see a student table
first, execute the select query for see the records of a student TV.
In the student table, we have a record by the values I before name Jessica and age 20, and we want
to change the value of this record.
So we go to the main function and create this query first.
We're the last quote
we could see a student with the idea.
Number four is existing student table, and we won't change the name and age values of it.
So create an instance of a student from a student distraught and initialize it.
First, define a variable like a student calling equals model dot student and initialize fields of this
object.
We want to change AI before.
So sit for four.
Decide.
And we want to change the name of Jessica to Jean.
So that came when you and you want to change the value of age from 20 to 30 age 30.
OK, now quick update function from DevTools package and sent created a student object as arguments
to it first define a variable like rose effect.
The rolls effect colored equals and calling update function from DevTools DevTools Dot update and set
a student arguements go to the next line and display Rove's effect value.
If the rules factor and set variable rules affect,
reformat the code and save the project and execute the program.
Go from the outback is clutch man made that go?
Now we can see the output rose affected one, go to the Maya school and see the changes I before the
name is Jessica and ages 20, now execute the select query and see changes.
Yes, the I.D. number for the name has changed too keen and ages 30.
The name and age of a student object is updated correctly in the person database and warned Rose is
affected in order not to prolong the time of decision.
Who will finish it?
And we will continue the content in the next session.
Goodbye.