1
00:00:10,980 --> 00:00:16,860
Hello and welcome to the Golang programming language course in the previous session, they could define

2
00:00:16,860 --> 00:00:23,970
two types of select methods, and in this session we want to create another craft functions.

3
00:00:25,740 --> 00:00:32,040
First, we want to create the function to insert a new student in a student table in person database,

4
00:00:32,730 --> 00:00:39,030
so define the function name, save that accept a student object as parameter.

5
00:00:39,300 --> 00:00:45,780
And if the addition of a student to the database is done correctly, the idea of the left added the

6
00:00:45,780 --> 00:00:48,450
student will be returned as written to us.

7
00:00:48,460 --> 00:00:57,960
So the right function save and sit a student as a parameter the student.

8
00:01:01,110 --> 00:01:07,380
Model art student and return type is gained sixty four.

9
00:01:09,600 --> 00:01:15,350
Now, Colin Kaepernick function for initializing MySchool driver name and data source name, so first,

10
00:01:15,360 --> 00:01:23,550
you can evaluate the light TV calling equals in Colin Kaepernick Thompson, who use Defer for closing

11
00:01:23,550 --> 00:01:35,940
the creator DB object ether theory the clothes after creating a DB object, the Invoke Pre permitted

12
00:01:36,120 --> 00:01:41,430
that creates a prepared statement for later queries or executions.

13
00:01:42,000 --> 00:01:47,330
Multiple queries or executions may be run concurrently from the return.

14
00:01:47,350 --> 00:01:53,640
The statement the caller must call the statements close metal when the statement is no longer needed.

15
00:01:54,330 --> 00:01:56,670
This function returns to values.

16
00:01:57,000 --> 00:02:03,180
First is still the object from a school package that is a prepared statement and the order.

17
00:02:03,180 --> 00:02:05,520
Is it all so defined?

18
00:02:05,520 --> 00:02:20,100
Too many events like Save Karma or Call an Equals DB Dot, prepare and write sweetin equity for created.

19
00:02:20,100 --> 00:02:21,960
The new object is a.

20
00:02:23,110 --> 00:02:39,310
Into the student by the name, age values, question mark, question mark, question mark.

21
00:02:39,520 --> 00:02:51,870
Now check our status if you know we're not equals need like the theater or dance at all.

22
00:02:54,850 --> 00:03:02,530
Now Corning exec metal at the Furnace school package and executes a prepared statement with the given

23
00:03:02,530 --> 00:03:07,420
arguments and returns a result summarizing the effect of this statement.

24
00:03:07,780 --> 00:03:15,730
This method returns to value first and object of reason interface, and the other is error so defined.

25
00:03:15,730 --> 00:03:27,550
Two variables like these are common in all calling equals save Dot Z and sit a student feels as are

26
00:03:27,550 --> 00:03:32,050
humans instead of question marks and prepare a statement sequentially.

27
00:03:32,320 --> 00:03:44,980
Like the student dot ie, the student does name and student starts h.

28
00:03:47,140 --> 00:03:56,770
Now, check in on his status if they're not equals, need large fat on their diet and or.

29
00:03:58,640 --> 00:04:06,050
Now calling last inverted I.D. function from a school package that returned the integer generated by

30
00:04:06,050 --> 00:04:08,810
the database in response to a comment.

31
00:04:09,260 --> 00:04:14,720
Typically, this will be from an ultra increment column when inserting a new rule.

32
00:04:15,080 --> 00:04:20,120
This function returns to value first in 1864 value, and the other is ill.

33
00:04:20,480 --> 00:04:36,770
So right two variables like student I.D. Comma Column equals resolved dot last insert I-T now check

34
00:04:36,770 --> 00:04:43,880
invalid status if they're not equals name like the fatal error dot.

35
00:04:44,030 --> 00:04:53,840
The rule now set a student ID and return type of save function, return to student IED, reformat the

36
00:04:53,840 --> 00:04:55,490
code and save the past.

37
00:04:56,240 --> 00:05:03,470
Now we could define the function names, save that accept a student object as parameter and save it

38
00:05:03,470 --> 00:05:08,300
as a record into the student table in person database and returns.

39
00:05:08,300 --> 00:05:12,170
The IED generated up to added new record by database.

40
00:05:13,310 --> 00:05:15,890
Now you want to create another function.

41
00:05:16,460 --> 00:05:23,360
In this case, we want to create the function to update is student in student table in person database.

42
00:05:24,770 --> 00:05:31,610
First, define the function name aren't dates that accept a student object as a parameter and returns

43
00:05:31,610 --> 00:05:33,290
the number of rows affected.

44
00:05:33,290 --> 00:05:34,700
So we write function.

45
00:05:35,490 --> 00:05:45,890
Update set a student variable from the student stocked model to art student and Return 1864.

46
00:05:47,920 --> 00:05:51,610
Now, cutting connect function for initializing mice will drive your name.

47
00:05:51,940 --> 00:06:01,720
So define a variable like DB calling equals and equal to cognitive function and set differ for closing

48
00:06:01,720 --> 00:06:03,010
the created the object.

49
00:06:03,490 --> 00:06:06,820
Ether did not close.

50
00:06:08,680 --> 00:06:14,320
After creating a DB object from a school package, we invoked preferred method that creates a prepared

51
00:06:14,320 --> 00:06:16,870
statement for later queries or executions.

52
00:06:17,300 --> 00:06:23,040
First, a stamp the object from a school package that is proof of a statement, and the order is it

53
00:06:23,050 --> 00:06:28,880
also defined two variables like alternate comma and column equals DB.

54
00:06:28,900 --> 00:06:36,580
Don't prepare and write suitable query for update and object update.

55
00:06:37,180 --> 00:06:52,060
Student city name equals question mark H equals question mark and set condition where I the equal question

56
00:06:52,060 --> 00:06:52,270
mark.

57
00:06:53,970 --> 00:06:59,340
Now, check errors there to his error not equals mean like that at all.

58
00:07:00,450 --> 00:07:08,640
Error dots, error now calling exec metal from a school package and executes a previous statement with

59
00:07:08,640 --> 00:07:13,680
the given arguments and returns a result summarizing the effect of the statement.

60
00:07:13,800 --> 00:07:20,430
This method returns to values first, not the result in interface and the other is it or so defined.

61
00:07:20,440 --> 00:07:22,710
Two variables like reason

62
00:07:25,170 --> 00:07:28,590
and column equals update.

63
00:07:28,920 --> 00:07:30,190
Dot exec said.

64
00:07:30,190 --> 00:07:34,710
The students use as parameter is the question marks in progress statements.

65
00:07:34,710 --> 00:07:47,310
Sequentially, the student not name comma student that a and for I.D. we said a student I.

66
00:07:48,930 --> 00:07:53,850
Now, check your status if they are not equals in law at all.

67
00:07:54,090 --> 00:07:54,900
They are not.

68
00:07:55,680 --> 00:08:02,700
There are now calling rolls effect that function from a school package that returns a number of roles

69
00:08:02,700 --> 00:08:06,150
affected by not date, insert or delete.

70
00:08:06,630 --> 00:08:10,950
Not every database or database driver may support this.

71
00:08:11,280 --> 00:08:19,890
This function returns to values first and in 64 value, and the other is it all so define two variables

72
00:08:19,890 --> 00:08:21,060
like roles.

73
00:08:22,900 --> 00:08:37,120
Affected and the rule calling equals resolved that roles affected check their status if they're not

74
00:08:37,120 --> 00:08:38,610
equals New Lodge.

75
00:08:38,840 --> 00:08:48,550
The fatal error Rodarte and or so will be defined roles affected variable void in 64 as return value

76
00:08:49,300 --> 00:08:53,940
return roles affected.

77
00:08:54,190 --> 00:08:54,540
OK.

78
00:08:54,640 --> 00:08:56,980
Perform at the code and save the project.

79
00:08:57,340 --> 00:09:04,840
Now we could define the function name update that exit a student object as parameter and update that

80
00:09:04,840 --> 00:09:10,660
record into the student table in person database and returns the roles affected numbers.

81
00:09:12,310 --> 00:09:14,470
Now we want to create another function.

82
00:09:15,220 --> 00:09:21,190
In this case, we want to create the function to delete a student from the student table in person database.

83
00:09:21,460 --> 00:09:28,810
So define the function name village that receives the idea of the record to be deleted in the input

84
00:09:28,810 --> 00:09:34,420
parameter and delete the records from the database and returns number of those affected.

85
00:09:35,320 --> 00:09:48,520
So we'll be right following delete defining variable like I.D. by the type end as parameter and 864

86
00:09:48,520 --> 00:09:49,930
as return value.

87
00:09:52,600 --> 00:09:58,240
Colin Conic function for initializing MySchool derive a name and data source name, so defining variable

88
00:09:58,240 --> 00:10:02,950
like DB calling equals and invoking conic function.

89
00:10:04,570 --> 00:10:07,900
And set offer for closing the created TBE object.

90
00:10:09,220 --> 00:10:09,820
Differ.

91
00:10:10,920 --> 00:10:12,630
David, up close.

92
00:10:17,140 --> 00:10:23,500
After creating a deep object, we invoke prepper method that creates a prepared statement for later

93
00:10:23,500 --> 00:10:35,260
cures or executions so defined two variables like delete comma error column equals dot prepei and write

94
00:10:35,270 --> 00:10:37,210
suitable query for delete and object.

95
00:10:37,360 --> 00:10:47,680
Delete from the student set condition where the equals question mark and take over say.

96
00:10:48,580 --> 00:10:55,880
If error not equals like the fatal error, got it.

97
00:10:56,060 --> 00:11:04,480
Or now calling Exec. method from a school package and executes a prepared statement with the given arguments

98
00:11:04,480 --> 00:11:12,340
and returns a result summarizing the effect of the statement so defined two variables like result and

99
00:11:12,550 --> 00:11:13,180
error.

100
00:11:13,450 --> 00:11:22,070
Pollen equals delete dot exists and sit a student I.D. as a condition for work laws that received it

101
00:11:22,090 --> 00:11:23,940
as input parameter instead.

102
00:11:23,960 --> 00:11:26,710
Question marks in prepared statement I.

103
00:11:28,640 --> 00:11:35,090
Now, check our status if they're not equals a lot fatter.

104
00:11:37,220 --> 00:11:44,420
And are now calling rolls effect function that returns the number of roles affected by an update, insert

105
00:11:44,420 --> 00:11:48,700
or delete, so define a variable like roles.

106
00:11:50,090 --> 00:12:04,320
Effected and call calling equals result that roles affected now check status status, if we're not equals

107
00:12:04,370 --> 00:12:17,180
nine lot fatter, older and or so we defined roles affected variable by the N64 as return value return

108
00:12:19,010 --> 00:12:24,950
roles fit, OK, reformat the code and save the project.

109
00:12:25,940 --> 00:12:32,780
Now we could define the function name leads that accept a student I.D. as parameter and delete that

110
00:12:32,780 --> 00:12:37,850
record from the student table in person database and return the roles affected.

111
00:12:37,850 --> 00:12:38,540
No.

112
00:12:39,110 --> 00:12:44,960
In order not to prolong the time of decision, we will finish it and we will continue the content in

113
00:12:44,960 --> 00:12:45,920
the next session.

114
00:12:46,250 --> 00:12:46,760
Goodbye.
