Headline welcome to the Golang programming language course in the previous session, we could define
the function name, select a student based idea, and in this session we want to create the function
to select all the students based the given name by sending a name to the database as the input parameter
of the select metal and all returning list of the students whose name is the same as the value sent.
So go to define this function.
Find set receiver for me to be assigned this method and the DB initialize arrested I.
So we write DB initialize or.
And the type is asked to resolve any.
Initialize the defined name of Method, select its Hugh Downs based name and define input parameter.
This method accept string value as name variable because it will return list of a student based name.
Name is strange and return type is two values first array.
All the students object, and second is an error value, so the right slice might allow a student in
error.
Now go to implement the body of function now by calling the DB initialize the value that we will have
access to the DB object from the strength of school package.
And through it, we can call the query method and executes the returns rolls.
Typically, as select, the arguments are for any placeholder parameter in the query query function
accepts estriol queries, statement as a strict parameter and returns to rows and URL object, so define
tool variable like roles and all roles.
And they're all calling.
He calls DV Initialize or dot and Dot query in this query.
We want to fetch list of students information whose name we have sent to the database as a query input
from her.
So we write select a song from the students their name equals, so the quotation marks and Sydney variable
as input value.
Now check entries.
That was so we right if they're not equals mean lot fattore.
That's her function.
OK?
One of the returned values of our mettle is a list of students, so we create an array of student etc.
to add to each new student that is read from the database, from the student data and at the end of
fetching data from the database, the students area is returned by the function.
So we write this to this column, equal area of modern dance students now put the return value of the
quality inside of Falou to access each of the rows by the next function.
So the wry blue rolls darts next function next function prepares the next result to roll for Reading
V desk and metal.
It returns true on success or false.
If there is no next is on a roll or an error happened while preparing it.
So we create an object from a student.
A strong student, Colleen equals model both a student
and colleague.
Eskin method on Rolls Resort to read recalls one by one.
Scan copies the columns in the car and throw into the various points that by destination.
The number of values in destination must be the same as the number of columns and rows defined, and
everybody invokes scan function.
Error equals rows dots function sit a student ideas point two percent The student thought ID
and sit a student name is going to ampersand student's name and set.
The student age is going to understand student age, Eskin Commerce, Collins read from the database
into defining common goal times in the special.
Times were white, but the school case, so check ED over status if or not equals mean sits log dot,
fattore or dot roll and continue.
Now we at each read record that contains a student to the list of the students by the append function
to append built in function at pins elements to the end of each slice.
So we write students equals happened students and students,
so return as students lease and Neal as return values of function per litre as students and.
Okay.
Reformat the code and save the project.
Now we could define the function name, select all the students by name that fits all students of a
student talent in person database by the given name.
In this session, we were able to design the database lower and create two functions in its role and
function to fetch a student based I.D. and one function to first niece of a student based on the given
name in order not to prolong the time of decision.
We will finish it and we will continue the content in the next session.
Goodbye.