Full transcript of “EPISODE 1 XAMPP MySQL CRUD”. Click a timestamp to open the video at that moment. Need another video? Use the YouTube transcript generator.
0:00 to our uh first episode of course for page so last time we discuss all about javascript as a client side scripting or programming language. So most likely yung JavaScript na discuss natin last time it's affect with the inter ng ating websites. But this discussion we will side which will be the server or the tin the server and databases which we save data from. So instead we use JavaScript use PHP specifically the software called Zap. So in order for you to start the activity or the uh instruction you are
0:45 required to download this app. So after niyo siya ininstall try to run it as administrator and yes after that um initially naka-uncheck to or naka-ex to para um pag run niyo ng computer or pag-restart niyo ng computer you don't have to manually turn this on and off. So ang gagawin niyo lang is i-click din both then click both as. Okay. So ganun lang yung setup natin with Zamp uh program. Zamp means cross Apache
1:31 MySQL PHP and meaning si Apache siya 'yung nag siya 'yung parang nagmumukhang local server. ating data ating web page. So in order for us to start uh the crude operations before we create or tamper with the crude operations sa PHP we must have a quick uh flip down with the MySQL. So i-click yung admin or at nagpa-pop up yung inyong ah webpage or yung inyong browser. So saakin I'm using Chrome. So wait niyo lang ong mag-load.
2:18 While waiting you can actually click the other one. Attach. So ibig sabihin nakita niyo na ong welcome design your application or your installments are actually um actually suful. So P Mar PHP wait lang natin to naglo-load ang ating local host then after niyo ma-install all of your applications or all of your um PHP files should be saved inside the HT box. So sir paano namin hahanapin yon?
3:05 So navigate kayo dito sa local sa this PC tapos andito siya sa zam and HT Docs. HT Docs ah um lagi niyong tatandaan yang folder na yan since dito naka-save lahat ng ating mga projects. So since first Sam I for midterm dito ko na sine-save yung ating mga files for the demonstration ng ating mga codes. Then you see right there this is the admin panel ng PHP admin. And in order for us to create or to store databases with the my page admin we must create a database first. So ganito lang siya.
3:50 Medyo mabilis lang siyang mag-create ng database pero hindi lahat ng pagkakataon is pwede niyong access ong gui. So delete ko muna to operations or ayan. So let's have a very quick um discussion about how can we create how can we store your databases. So this discussion should suppose to happen na FBS. I'm not if I'm not mistaken dapat nasa FBS niyo to. And pero anyways, let's uh start
4:38 over again with the uh introduction of database specifically for the PHP. So pagclick niyo yung new lalabas yung databases. Then what will be the database name? Any names that you want to um call your database. So dito I will name it as is the as this is the database for isda create isang database kasi just like your excel si database and excel are both the same. So isang table na to okay so this entire sheet is what we call a spreadsheet. Tama. Yes. Then ang
5:27 counterpart ng database dito sa PH sa PHP is the entire grade book. Dito naman sa Excel and different grade book has different sheets. Different sheets different datas. Ngayon dito meron din tayong different kind of tables. For example table name it has student and the student theta has four columns. Yung four columns na to siya nagdi-discuss or siya na-explain ng attribute ng isang student. So let's create that then
6:14 we have your primary keys. So kada entry kasi natin ng data sa database nagi-i-increment yung tinatawag natin mga IDs. So let's say we have your student ID here. Okay? Student ID. And nung pagka-enroll niyo 'di ba hindi na hindi niyo naman pinili ung student. So ang student ID natin could be longer pero by default I will say it as an digit long. Okay. Oops. So huwag muna yan. drop. Huwag niyo na munang i-enter. Tayo ulit ng ayan
7:01 tayo ulit ng natin to. mabilis yan so wala ulit create tayo ng student then yung four columon discuss all about the attribut create then student Then I number it has a Lu. Then i-check niyo yung AI. Me ng AI is auto increment. So kada new student uh
7:47 data yung student ID niyo ah nag-i-increment siya from zero naging 1 2 3 4 5 then syempre student has its name plus name then f then let's say each so we have your types here anong type ng data ang student id it is an integer ang name is not an integer so we must change that into chart then name is not so barchar din yon then ang longest name na alam ko hindi naman nag-exceed ng 50 characters yan so 50 characters
8:34 characters at wala naman sigurong umaabot ng 1000 years old so ang characters ng age would be Okay. So the characters I'm talking is 100. So this is three characters. Okay. So four characters that would be 1,000. Wala naman siguro nakaabot na age na 1,000. So let's go back with student ID. Um student ID ko kasi is 20182. So ilan to? 3 6 9 10. O so mayon akong 10. And after that we must click
9:19 then we actually have your student table. Sir, paano pag nag-create ka ulit ng isa pang table? That means this student table stores only student data. Paano pag teachers table? So okay si teacher meron din siyang employee ID. So instead na student ID, employee ID naman yung sa kanya. Then number meron siyang 10 values din then meron auto increment din siya. ganon din name saka sa vir
10:07 So so meaning I have two tables here. Student hold student data teacher holds teacher data. So that is the two basic common um filing ng ating mga data. So sir paano tayo maglalagay ng data diyan? Insert data. So click niyo ong insert then pwede na kayong maglagay ng value dito. So student data kahit niyo lagyan ng value yan okay lang kasi nag-autocrement. So let's say my name is here. I'm a student then my age is 20. Then click niyo yung go then click niyo yung browse.
10:54 So meron tayong student data here. One assim left. So that is how can we create data using the uh using the insert function. Now how can we create a that is the create function na insert is create function. How can we edit? Click natin yung edit doon. Then simply edit the data that you want. Redson siya. Redson na yung last name. Then go. So ayuned na yung last name niya. So paano kung gusto ko naman siyang i-delete? Then click mo lang yung
11:40 that is already the code operation inside your ah myql php myql uh dashboard. Pero sinabi ko nga na hindi tayo usually or not all the time will use the GUI ng my PHP admin. What I'm uh teaching you today would be how can we actually create a database without touching the UI. So how can we do that? So click muna tayo dito operations then routines pala rather. Then hanapin natin yung drop database. Drop database. Deleting the entire database including the uh
12:28 the tables. Yun. Then we go with the SQL. So we will create uh database from scratchs. So E start natin by using E. Then the database name ha. Then semicolate database then dang so madali lang create database name app then click mo yung
13:13 so na siya Okay. Ngayon para tayo gagawa naman ng table. Ayan. So create then meron tayong open and close parenthesis here. We should define first the column name. So let's say student ay then So check natin here yung data dito
14:03 na sila dito I created a Ah swit here kanina yan. So how to create a table using this type of or this is the syntax on how can you create table. So tayo table that the table name so student then then column so for example I student I data type will be hard chart I know it's
14:52 integer Then sa loob niya, open and close parenthesis ilan yung length niya? So kanina that's 10. Okay. and the F name or L then it is virtual sorry then the length will be 50 siguro ko lang to then last so B so is
15:40 it is an image and yung line niya will be so makita niyo meron tayong error dito since uh the div the division of the column should have Start here then the delimiter comma then the delimeter comma delimeter comma then pag last na you don't have to add theimeter comments so tanggal niyo yon para mawala yung error then click so that is how create your table right now good na tayo sa pag-create ng
16:27 database mag-create ng date table So mag-create tayo ulit ng isa pa. Review natin yung SQL yan. Now, how can we create or how can we destroy a table? So let's try to create a table na lang dito para mabilis. So ah medyo dayain ko na lang. Just just ano just the fact na mapakita ko sa inyo how to destroy it. How can it destroy this as the visa table? Click niyo SQL
17:13 ah by manually ah by using this command table then table name then go. Nagtatanong siya kasi nga uh PHP destruction of uh data within uh PHP magtatanong siya ng ah mismong mga confirmation. So this is a what? This is kind of a confirmation or confirm. Okay. So na-destroy na yung ating data. So how can we actually uh let's start by um reading first.
18:01 So C data or by uh C database in order for it as or in order for it to display data it actually use select functions. Select select ko daw lahat ng nasa student data. Select all from student data. So kunin ko daw lahat ng nasa student data. So go to technically wala siyang binalik since wala pa namang naman si student data. That is how can we actually read. So
18:47 wala pa naman tayong nare-read. So let's skip the read function and we go to the insert function. So SQL then instead na select we actually use the term insert. insert. So dito tayo insert into table name which is student data then column stock. So since natin makita expound natin to. Yan. makita natin yung mga columns here.
19:34 Meron siyang student ID then L then insert into table name. This is the table columns values value 1 value 2 value 3 value 4. Now kung paano to naka-arrange dapat ganun din yung value na nakaarrange. So student ID should be student ids. So tanggal dito and tama dapat yung ine-insert niyong type ng data type.
20:20 Kung student ID to hindi dapat kayo maglalagay ng double code since made-detect niyo yan as string at it will actually give you an error. For example, na natin to. So h nag-insert siya. So let's check nga kung tama yung insert. So ah oo nga pala auto increment pa kasi to. Auto increment si student ID. Browse natin siya. Student ID is 3. Pero actually pwede nawala yun. So balik tayo dooun sa ah balik tayo doun sa SQL. Let's here.
21:09 Mm. then values gan din ano yung value niya actually pwedeng blank So lang yan then LD will be al same and
21:56 then see the age is R24. Okay. So it should start or it should enter kasi nga auto increment is okay lang kahit walang si primary or the auto increment. So low oops meron tayong issue. Ayon incorp integer value student ID. Ayun oh. So na-detect niya na a sa kanina okay lang yun kasi number pa din yung ininput natin. So since it is auto increment kahit wala na yan kahit wala ng data yan
22:41 natin. Okay. So meron pa din siyang error. Tanggalin natin na natin siyang then. So what if lagyan natin siya ng let's say one? So ayun tinanggap niyo na kasi yung one is i browse natin. Ayun. So we actually have data here. So paano natin siya ipi-print or paano natin siya kukunin? Paano natin siya i So structure SQL. So sabi niya i-display mo lahat. Select
23:26 all from student data naman to. Select all from student data. pinakita niyo lahat yung results sa akin. Alr. So ah medyo konti to at gusto ko dapat siya damihan. Okay so tutulong ah hingi tayo ng tulong sa AI to have more data. So gawin ulit natin yung template select into insert into student data then the column means
24:12 then l then h then values Ayan ito number two. So pag ginawa niyo ulit one to magkakaroon kayo ng conflict. So try nga natin yun card. Let's say so muna to. Then gawin ko onong one. So tignan niyo yung conflict niyan. So existing na kasi
24:58 yung student number, student data, student ID na one. So sabi ni ni ano sabi ni MySQL hindi na hindi kami tatanggap ng duplicate entrance. Okay let's see bakit tinanggap. Ewan na ba tayo? Ah hindi kasi siya unique. Okay. O hindi siya unique kaya naga-accept siya ng ID kasi specifically student ID it should not it should not be duplicated.
25:43 Baka may lang tayo dito na click to attributes dapat yung sige natin siya anyway sige ah move tayo ulit so ide-demo natin on how can we actually create ah or how we read ng madami. So hingi tayo or hingi tayo ng tulong sa deep seek. Ito yung ginagamit ko na just to provide
26:29 model or just to provide hingi siya ng GPT. So for the dami data hingi tayo ng tulong kay AI. Um for this. So ito yung ating SQL curry. Say ah 300 student ha. Hindi ayoko to mo na dito na.
27:18 vals. Ayan so ganito so gusto mong mag-insert ng madaming data so ganito siya kahirap. So ima-manually mo siya. So humingi tayo ng tulong dito just to have um yun just to have so sige okay na tayo siguro sa 60 na natin to then let's try to insert them over
28:04 so madami Ah yan. So pwede naman na nandito yung values. Pwede rin naman siya na nandiyan. Okay lang as long as kumpleto yung inyong. Soalin ko lang pa ako sa order vales. So let's try to run. So na-insert na yung 60 rows. Check natin kung na-insert nga siya. Ayun. So may mga na-insert na data.
28:50 Noah um so let's try to retrieve naman the data so select kung all lalabas all kung gusto ko age lang so each lang yung select from student data then go so ang lalabas lang is yung column ng Right. So tayo doun sa query box select f name from data. So lalabas lang diyan with sun ang purpose nung all. Meaning kasi ng star or ng found is select all from
29:38 student data. Then so lumabas lahat. Right. So paano kung sir gusto kong ah lumabas lang si F name tsaka si LN select F name L from student data then ayun so lumabas lang yung F name and L name. So select means retrieving. This is actually your This is actually your hashtag pala yung comment ko. This is
30:25 the read that this is the yung insert kanina is what we call the create insert into ah link. tapos volumes then value and the so this is what you call your part this is what you call the part now creat so okay na tayo sa read and create. So si read madami pa siyang functions hindi lang ganito. Actually meron tayong
31:11 tinatawag na end tsaka or meron tayong tinatawag na where. Okay? So instead na ah isipin niyo na lang si read or si select function or si select or this read can filter not only the columns but the data sa loob ng mga columns naon. So let's duplicate this side by side. para makita natin yung lamang structure ng data dito sa browse natin. So what if gusto ko ah i-print lahat ng may age na 20? So how can we or how can I do that? So
31:58 gusto kong ilabas lahat ng table. So that means select all. So lahat ng columns is lalabas ngayon from student data but we can actually delimit it using the where cla where. Okay. Ano yung tina-target natin na age where age is greater than or is equals to let's say or equal to 20. So technically gusto ko lang i-retrieve lahat ng student na may age na 20. So how can I do that? Age is equal to
32:46 Okay. Then so lahat lang 20 na may issue lumalabas. Okay. Paano kung gusto ko yung mga greater than click ko yung ah less than pala yun sorry yan greater than 80. So lumabas yata sila lahat except yung 3 years old kasi yun lang yung ah less than. Okay. So paano kung gusto ko pa siyang
33:32 i-enhance? So the work means ito yung condition part. So this is the condition part. So ito yung gusto mong gawin or ito yung gusto mong condition niya. So select all from Ito yung how it is presented. Present sended. Okay. So select lahat kukunin ko lahat from student data. So kung sinabi mo lang F name F name column or lahat ng F name so ibig sabihin F name colum F name column lang
34:18 yung babalik so pag lahat lahat ng colums yung balik ito yung tinatawag mo na condition where age is greater than AP or where name like for example L name is equals tayo doon na may L na may same sila na Lang the same okay kahit isa na lang where L is equ to Ramos Rivera
35:12 So vera lang yung laman. What if um age pa din greater than ah 21 greater than or equals to? So yun yung ah nakaarrange ngayon paano kung gusto ko naman siyang nakaort? Ito kasi naka ah this will be the condition na lahat ng age 21 is magpi-print and lahat ng table or lahat ng data is mape-present.
35:59 So meron tayong tinatawag na another clause which is order buy. Order by means how it is sorted. So kung order by age send ASC mean naka-order daw ba siya? Naka-order siya by age ng naka-assending format. So this is condition more condition the short condition short okay so natin to so naka-start siya by ascending order
36:50 bakit may number the do check natin yung query or less than pala to gawin ko ong Yan. So naka-sort siya by each na naka-assending. So ASC yon. Paano pag descending? BSC naman siya. pag descend or d or hindi siya nag-aano siya ndecend o desk yan pala desk descendan
37:36 then go so from later to bigger. So paano kung ayoko naman siya naka-sort by H. Gusto ko naka-sort siya by FN at naka-assending. Ibig sabihin mauuna yung A papunta kay Z. Check na natin. So ayun Adrian, Alex, Axel ayang kay so naka start siya by F. So what will happen if I do this student ID asend? So dito siya magbabase sa student. So go natin. Also nakaassort
38:24 siya by your student. That is how can we create or so that is how can we do the multiple filtration method ng tinatawag natin na read. It is actually meron siyang many parts. How it is presented, what is the condition and how is the sort condition. Okay? So check na natin dito. Baka meron pa tayong nakaligtaan. Ah meron pa tayong ah yung OR. I think may OR pa tayo dito yung N tsaka. So let's say ah magco-compound tayo dito sa condition. So you know naman na this should be true when it comes to end.
39:14 Example end. F name starts with Ana. So this condition throws two compound uh statements. This part will be true and this part should be true. So tigan natin kung meron ba habang na greater than 21aka first name will be anesh ko to. So this is the unfiltered version. Although through itong nasa kabila the other one returns as false. Meron ba
40:00 tayong student na may award na Anna? So Anna na may ayon sige Anna na may double n yung akin pero ano na yung nandito. So let's see kung meron siyang ibabalik na output. So successful siya although wala siyang binalik na ah wala siyang binalik na student si binalik dito. It means na yung qu is not wrong pero wala lang talaga siyang nahanap na nag-satisfy nung kanyang conditions. Okay. If we correct this, hanapin niyo yung may age na 21 at meron din siyang naan.
40:51 So wala pa din. Let's see kung ilan yung age ni Anna. 19. So hindi naman niya na-satisfy yung sa kabila. Hindi naman na-satisfy yung age. So let's actually do less than 21. So diyan meron na kasi nga yung dito dito ni Anna 19 tapos yung name niya would be then. Ayon. So in order for the query or the database to find this using the end or to satisfy this condition
41:38 uh those two sent two compounds uh statements should be true. Paano pag ginawa ko or okay so may lalabas diyan ah sa dala ah either of the two should be true. For example ito is equals to 100. Wala naman tayong student na may 100 na age pero meron tayong student na may F may f name na an. So pag ginoo ko 'to lalabas pa rin si Ana. Although yung age niya is hindi 100 kasi we use the four. So even if nag-false to or wala siyang nahanap na each is equ to 100, may
42:24 nahanap naman siyang anak. Okay? So paano niyo nahanap si So age is equ to 100 or F name is P. So wala naman siguro tayong student dito at wala din tayong student na may pangalang. So walang lalabas na student data. So that's it for our reading or that is for our meron tayong three major parts. You have your condition and slash 4. Then order by kung paano siya nakasort via condition. So tatlo yung parts ng
43:12 ating read condition. Insert yun lang. insert then into the table name table followed by its table column followed by the value preserve data for h so ito yung ating part naman ng So the two left na lang will be the update and the delete. So ito lagyan ko siya ng
44:00 star here. This will be the lead part. This will be the creative part then we will do the delete part. delete part is almost the same with read pero ang kailangan lang nian si read will be the wear class. So pag sinabi mong delete from the table name say student data data where student id is equ to
44:55 Tanggalin ko muna to. Delete from student data where student ID is equ to 1. So ilan yung student natin na may student? Tatlo. Tama. So ag wala ito hindi ko mamaya ko ide-demo pag wala agag wala kasi siyang tinatawag na we close m-delete siya. Okay. So, delete from student data where student ID is equ 1. Pwede ring or ayan meron siyang or statement doon or
45:41 f equals to lian. BMan. So pwede pwede yung condition natin dito is complex. We we use Nsaka R. Pag inand ko to hahanapin daw niya yung student na may student ID na one at pangalan niya Liam. So pag kinon ko 'to for example I did this I did go. Wala siyang dinelete kasi wala nga siyang nahanap na student. Mayro'ong student ID no one. At the same time pangalan is
46:26 naman siya nag-match don. So wala siyang minelete. So let's uh delete that first. Yan. Then go. So meron daw siyang tatlong na-delete. So once I refresh this table dapat wala na si Mard and Wala na sila. We are both deleted. So na-delete na 'yung mga data na 'yon. Okay. So, how about i-delete ko yung may mga age na kasi okay
47:12 may mga pangalan na may age na 22 yan gusto ko muna gusto ko munang tignan kung kung sino yung mga is na 20 so select all from student Where is a f
48:03 So ito yung mga 22. Pag in-execute ko 'to, lahat ng merong isa 22 will be deleted. So 12 rows are deleted. Pag ni-refresh ko 'to, dapat wala na siyang data. So wala na. That's the browse function. Meron ba tayong ano dito 22? Wala nab. So that is for our delete function. Dapat meron siyang tinatawag na condition where age is equ to 22. Let's do naman the Yan. Pun na din siya dito. Although meron naman na siya dito.
48:53 Ay send ko na lang ito. Send ko na lang to. How about the update a certain kind of for example ito nagkamali ako rito kanina gusto kong baguhin to it should not be 33 so let's have the update. from student what will be the update from student data
49:42 update. Ayan, update pala siya. Update student data. Set column. Ano iyung target kong column? Set LC. So kung gusto mo pong maging yung isa yan para okay lang kahit ganito basta tama yung
50:37 Yan set ito. Yung ito 'yung ia-update mong data ngayon. Ano yung tina-target niya na old data? Okay. For example, dito ano sa siguro ano yung magiging marker ko dito para ma-update ong mga data ko na to? My marker should be a primary key, the number three. So yun ang kahalagahan ng primary key na sinasabi ko kanina na this should be unique. Sir, paano pag may dalawang three? So ang update niya, dalawa silang maa-update. Dapat yung primary key should be unique at the same time autogenerated siya. So
51:24 where student ID is equals to an student ID ko? 3. So siya yung tina-target. Okay. So, update table name set column name to the data column data column column name data. Ito iyung condition where student id. Okay. So if then click mo yung go. So merong one affected. Pag nine-refresh ko to at malaman ko na nack siya. Then
52:11 there you go. Na-update na yung ating naapit nga yung ating data for that. So goods tayo doon. Ang problema nga lang dito agag hindi clear yung target natin where student ID uh is equals to for example sinabi mo nilagyan mo dito ng or f name equ to siap let's say I want to
52:58 Ito yung i-inject natin na data dito sa specific specified na place na to. So pag nahanap niyo yung 14 kasi nga or to or let's say end and hanapin yung student ID na 14 which is this. So ma-update si Franz Fernandez Noa ng ah 20 tsaka si F name na my sopia F name na my So yun so when I actually do this zero effective ah kasi nga naka-end pala
53:45 yun wala naman tayong yung data entry ng Sopia at the same time student student ID niya is 14 kasi si Sopia dito is 9. So let's try to order this. So target niya yung may student ID 14 tsaka may F name na sa field. So two rows are affected. Pag ni-refresh ko 'to yung merong 14 which is this tsaka yung merong entopia which is this are accepted. So see nawala na si Sofia at nawalan na rin yung ID.
54:31 So the wear cross sa lahat ng part is very important. So as long as clear dapat yung we close mo hindi ka magkakaroon ng problema. Okay? So let's try to delete the data. Wala kang work. from student work at nawala na lahat yung data mo so again we
55:16 clause is very important in all aspects of deleting and updating. So sa reading ah maganda okay lang naman kahit gaanong specified yung work mo sa reading. Si inserting wala naman siyang works. So careful tayo sa paggamit ng weclass so I think that's it for our ito lang naman yung kailangan niyong malaman when it comes to the four major parts of CRUD. This four or this five is for this is for
56:02 creating is foring then this is So um is itutuloy ko na how can we actually ah hindi sige on the next episode we will try to continue or we a database at ico-connect natin siya sa PHP. So PHP file connects or let's say the front end connect with the back end which is the
56:49 then PHP connects with patch then a patch connects with the DBMS specifically kay my SQL okay so this is like the flow one end this is the inputs from the user backend processes it process and checks it then dad sache kung meron siyang save sa database siya so ito yung gagawin natin next discussion or next episode ng ating cash course for your uh for your what we call this um discussion for page. So na-discuss ko na yung may
57:35 SQL version ng mga ito. Paano naman natin siya gagamitin sa front page. So with that, I'll see you in episode number.