1 00:00:11,870 --> 00:00:16,610 Hello and welcome to the golden programming language course in this session. 2 00:00:16,640 --> 00:00:23,360 We want to create another function to update student in student table in person database. 3 00:00:24,710 --> 00:00:31,250 So go to the TV connection, find and created our new function. 4 00:00:33,260 --> 00:00:41,060 First, define it function named update that accept student object as parameter and returns the number 5 00:00:41,060 --> 00:00:42,170 of rows affected. 6 00:00:42,350 --> 00:00:55,040 So we write phone update set a parameter as a student by the time the student of modern. 7 00:00:58,620 --> 00:01:01,860 And return times and 64 value 8 00:01:05,190 --> 00:01:11,250 next calling clinic function for initializing my screwdriver name and data source name. 9 00:01:12,450 --> 00:01:18,820 First, define a variable like call calling equals and calling conic function. 10 00:01:22,710 --> 00:01:24,190 Use D3 for closing. 11 00:01:24,300 --> 00:01:29,060 Create a TV object, the Ether TV dot close. 12 00:01:32,940 --> 00:01:39,210 After creating a DV object from a school package, the Invoke prepper method that creates a prepared 13 00:01:39,300 --> 00:01:46,410 statement for later callers or executioner's multiple queries or executions may be run concurrently 14 00:01:46,560 --> 00:01:48,360 from the return to the statement. 15 00:01:48,780 --> 00:01:50,850 This function returns to values. 16 00:01:50,850 --> 00:01:57,030 First isn't the object from a school package that is a prepared statement, and the order is erotic. 17 00:01:57,360 --> 00:02:03,740 So first, define two variables like object and or update comma. 18 00:02:04,320 --> 00:02:14,820 Column equals and calling prepar function on the object DB to prepare now, write suitable query for 19 00:02:14,820 --> 00:02:16,200 object and object. 20 00:02:16,860 --> 00:02:18,510 So we write update. 21 00:02:20,860 --> 00:02:21,820 A student. 22 00:02:23,240 --> 00:02:26,240 Said name. 23 00:02:27,430 --> 00:02:41,020 Equals instead of value, we said question mark and age equals sit and other question marks instead 24 00:02:41,020 --> 00:02:52,720 of value for age and set virtual laws as condition where I.D. equals and sit and other question mark. 25 00:02:53,770 --> 00:02:54,090 Okay. 26 00:02:54,190 --> 00:03:04,210 Go to the next line and check a status if there are a lot of that error that they are 27 00:03:08,140 --> 00:03:14,650 now cutting exec method from a school package and executes a prepared statement with the given arguments 28 00:03:14,890 --> 00:03:19,090 and returns a result summarizing the effect of this statement. 29 00:03:19,420 --> 00:03:26,290 This method returns to value first and object of result interface, and the other is and a raw object 30 00:03:26,650 --> 00:03:37,270 so defined to Abi's life result and error result, comma error column equals and column exit function 31 00:03:37,270 --> 00:03:41,800 on the update object update dot exec. 32 00:03:42,220 --> 00:03:47,950 And so the student fills as parameter instead question marks in further statements sequentially. 33 00:03:48,220 --> 00:03:50,020 First, the student may. 34 00:03:53,530 --> 00:03:55,540 Second, a student at age. 35 00:03:59,780 --> 00:04:03,230 And sit a student IDs condition for their clothes. 36 00:04:03,920 --> 00:04:07,550 Student got I.D.. 37 00:04:10,470 --> 00:04:12,090 Now, take Aurora status. 38 00:04:21,850 --> 00:04:27,160 Now, cutting roads affect effective function from a school package that returns the number of roads 39 00:04:27,160 --> 00:04:30,520 affected by an update, insert or delete. 40 00:04:31,120 --> 00:04:35,380 Not every database or database driver may support this. 41 00:04:35,800 --> 00:04:41,720 This function returns to values first in 1864, when you and the other is, aren't there? 42 00:04:41,720 --> 00:04:49,870 Or so we write two variables like roads affected and it all roads affected. 43 00:04:50,230 --> 00:04:57,430 Comma L equals resolved dirt roads affected. 44 00:04:58,630 --> 00:05:01,690 Go to the next line and check error status. 45 00:05:06,100 --> 00:05:10,750 And return roads affected as return value later. 46 00:05:11,700 --> 00:05:12,180 No. 47 00:05:13,150 --> 00:05:20,350 But that reform of the court and say the project now, we could define the function name update that 48 00:05:20,350 --> 00:05:27,070 accepted a student object as parameter and object that we call into the student table in person database 49 00:05:27,280 --> 00:05:29,190 and returns the roles affected? 50 00:05:29,200 --> 00:05:29,800 No. 51 00:05:30,340 --> 00:05:37,060 Before we move on to go to the main function, we go to the MySchool database and see a student table 52 00:05:37,390 --> 00:05:42,710 first, execute the select query for see the records of a student TV. 53 00:05:44,500 --> 00:05:52,210 In the student table, we have a record by the values I before name Jessica and age 20, and we want 54 00:05:52,210 --> 00:05:54,730 to change the value of this record. 55 00:05:54,790 --> 00:06:00,150 So we go to the main function and create this query first. 56 00:06:00,190 --> 00:06:01,420 We're the last quote 57 00:06:05,170 --> 00:06:07,530 we could see a student with the idea. 58 00:06:07,530 --> 00:06:13,480 Number four is existing student table, and we won't change the name and age values of it. 59 00:06:13,480 --> 00:06:19,990 So create an instance of a student from a student distraught and initialize it. 60 00:06:20,140 --> 00:06:29,830 First, define a variable like a student calling equals model dot student and initialize fields of this 61 00:06:29,830 --> 00:06:30,370 object. 62 00:06:33,490 --> 00:06:35,320 We want to change AI before. 63 00:06:35,710 --> 00:06:37,600 So sit for four. 64 00:06:37,600 --> 00:06:38,080 Decide. 65 00:06:39,190 --> 00:06:42,760 And we want to change the name of Jessica to Jean. 66 00:06:44,680 --> 00:06:56,110 So that came when you and you want to change the value of age from 20 to 30 age 30. 67 00:06:56,890 --> 00:07:04,210 OK, now quick update function from DevTools package and sent created a student object as arguments 68 00:07:04,210 --> 00:07:08,140 to it first define a variable like rose effect. 69 00:07:08,140 --> 00:07:22,360 The rolls effect colored equals and calling update function from DevTools DevTools Dot update and set 70 00:07:22,360 --> 00:07:28,180 a student arguements go to the next line and display Rove's effect value. 71 00:07:29,200 --> 00:07:38,740 If the rules factor and set variable rules affect, 72 00:07:41,770 --> 00:07:45,940 reformat the code and save the project and execute the program. 73 00:07:48,520 --> 00:07:53,920 Go from the outback is clutch man made that go? 74 00:07:57,740 --> 00:08:07,070 Now we can see the output rose affected one, go to the Maya school and see the changes I before the 75 00:08:07,070 --> 00:08:12,900 name is Jessica and ages 20, now execute the select query and see changes. 76 00:08:14,630 --> 00:08:20,840 Yes, the I.D. number for the name has changed too keen and ages 30. 77 00:08:21,380 --> 00:08:27,620 The name and age of a student object is updated correctly in the person database and warned Rose is 78 00:08:27,620 --> 00:08:30,860 affected in order not to prolong the time of decision. 79 00:08:31,010 --> 00:08:32,000 Who will finish it? 80 00:08:32,000 --> 00:08:34,730 And we will continue the content in the next session. 81 00:08:34,910 --> 00:08:35,450 Goodbye.