Hello and welcome to the Golang programming language course in the previous session, they could define
two types of select methods, and in this session we want to create another craft functions.
First, we want to create the function to insert a new student in a student table in person database,
so define the function name, save that accept a student object as parameter.
And if the addition of a student to the database is done correctly, the idea of the left added the
student will be returned as written to us.
So the right function save and sit a student as a parameter the student.
Model art student and return type is gained sixty four.
Now, Colin Kaepernick function for initializing MySchool driver name and data source name, so first,
you can evaluate the light TV calling equals in Colin Kaepernick Thompson, who use Defer for closing
the creator DB object ether theory the clothes after creating a DB object, the Invoke Pre permitted
that creates a prepared statement for later queries or executions.
Multiple queries or executions may be run concurrently from the return.
The statement the caller must call the statements close metal when the statement is no longer needed.
This function returns to values.
First is still the object from a school package that is a prepared statement and the order.
Is it all so defined?
Too many events like Save Karma or Call an Equals DB Dot, prepare and write sweetin equity for created.
The new object is a.
Into the student by the name, age values, question mark, question mark, question mark.
Now check our status if you know we're not equals need like the theater or dance at all.
Now Corning exec metal at the Furnace 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 reason interface, and the other is error so defined.
Two variables like these are common in all calling equals save Dot Z and sit a student feels as are
humans instead of question marks and prepare a statement sequentially.
Like the student dot ie, the student does name and student starts h.
Now, check in on his status if they're not equals, need large fat on their diet and or.
Now calling last inverted I.D. function from a school package that returned the integer generated by
the database in response to a comment.
Typically, this will be from an ultra increment column when inserting a new rule.
This function returns to value first in 1864 value, and the other is ill.
So right two variables like student I.D. Comma Column equals resolved dot last insert I-T now check
invalid status if they're not equals name like the fatal error dot.
The rule now set a student ID and return type of save function, return to student IED, reformat the
code and save the past.
Now we could define the function names, save that accept a student object as parameter and save it
as a record into the student table in person database and returns.
The IED generated up to added new record by database.
Now you want to create another function.
In this case, we want to create the function to update is student in student table in person database.
First, define the function name aren't dates that accept a student object as a parameter and returns
the number of rows affected.
So we write function.
Update set a student variable from the student stocked model to art student and Return 1864.
Now, cutting connect function for initializing mice will drive your name.
So define a variable like DB calling equals and equal to cognitive function and set differ for closing
the created the object.
Ether did not close.
After creating a DB object from a school package, we invoked preferred method that creates a prepared
statement for later queries or executions.
First, a stamp the object from a school package that is proof of a statement, and the order is it
also defined two variables like alternate comma and column equals DB.
Don't prepare and write suitable query for update and object update.
Student city name equals question mark H equals question mark and set condition where I the equal question
mark.
Now, check errors there to his error not equals mean like that at all.
Error dots, error now calling exec metal from a school package and executes a previous statement with
the given arguments and returns a result summarizing the effect of the statement.
This method returns to values first, not the result in interface and the other is it or so defined.
Two variables like reason
and column equals update.
Dot exec said.
The students use as parameter is the question marks in progress statements.
Sequentially, the student not name comma student that a and for I.D. we said a student I.
Now, check your status if they are not equals in law at all.
They are not.
There are now calling rolls effect that function from a school package that returns a number of roles
affected by not date, insert or delete.
Not every database or database driver may support this.
This function returns to values first and in 64 value, and the other is it all so define two variables
like roles.
Affected and the rule calling equals resolved that roles affected check their status if they're not
equals New Lodge.
The fatal error Rodarte and or so will be defined roles affected variable void in 64 as return value
return roles affected.
OK.
Perform at the code and save the project.
Now we could define the function name update that exit a student object as parameter and update that
record into the student table in person database and returns the roles affected numbers.
Now we want to create another function.
In this case, we want to create the function to delete a student from the student table in person database.
So define the function name village that receives the idea of the record to be deleted in the input
parameter and delete the records from the database and returns number of those affected.
So we'll be right following delete defining variable like I.D. by the type end as parameter and 864
as return value.
Colin Conic function for initializing MySchool derive a name and data source name, so defining variable
like DB calling equals and invoking conic function.
And set offer for closing the created TBE object.
Differ.
David, up close.
After creating a deep object, we invoke prepper method that creates a prepared statement for later
cures or executions so defined two variables like delete comma error column equals dot prepei and write
suitable query for delete and object.
Delete from the student set condition where the equals question mark and take over say.
If error not equals like the fatal error, got it.
Or now calling Exec. method from a school package and executes a prepared statement with the given arguments
and returns a result summarizing the effect of the statement so defined two variables like result and
error.
Pollen equals delete dot exists and sit a student I.D. as a condition for work laws that received it
as input parameter instead.
Question marks in prepared statement I.
Now, check our status if they're not equals a lot fatter.
And are now calling rolls effect function that returns the number of roles affected by an update, insert
or delete, so define a variable like roles.
Effected and call calling equals result that roles affected now check status status, if we're not equals
nine lot fatter, older and or so we defined roles affected variable by the N64 as return value return
roles fit, OK, reformat the code and save the project.
Now we could define the function name leads that accept a student I.D. as parameter and delete that
record from the student table in person database and return the roles affected.
No.
In order not to prolong the time of decision, we will finish it and we will continue the content in
the next session.
Goodbye.