Difference between revisions of "PHP-and-MySQL/C3/MySQL-Part-3/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 4: Line 4:
 
|-
 
|-
 
|0:00
 
|0:00
|નમસ્કાર, તમારું ફરીથી સ્વાગત છે. આ ટ્યુટોરીયલમાં આપણે એક ડેટાબેઝમાં કેટલાક ડેટા લખીશું.
+
|Hi, welcome back. In this tutorial we will write some data into a database.
 
|-
 
|-
 
|0:06
 
|0:06
|આ કરવા માટે આપણે આપણા '''"mysql query"''' ફંક્શનને ઉપયોગમાં લઈશું.
+
|To do this we will use our "mysql query" function.
 
|-
 
|-
 
|0:10
 
|0:10
|હવે તમે અહીં જોઈ શકો છો કે આપણી પાસે આપણા... રેકોર્ડ છે....
+
|Now you can see here that we have our... records....  
 
|-
 
|-
 
|0:16
 
|0:16
|હું આ ટ્યુટોરીયલને ફરીથી કરી રહ્યો છુ કારણ કે જયારે મેં પહેલી વાર આ કર્યું હતું, આ કામ કરતુ ન હતું.
+
|I am redoing this tutorial because the first time I did it, it did not work.  
 
|-
 
|-
 
|0:21
 
|0:21
|તો સૌપ્રથમ, હું અહીં આ ડેટાને રદ્દ કરીશ.
+
|So first of all, I will just delete this data here.
 
|-
 
|-
 
|0:29
 
|0:29
|સારું... ઠીક છે... તો આપણી પાસે એક ખાલી કોષ્ટક છે, આપણા કોષ્ટકમાં આ સમયે કોઈપણ ડેટા નથી.
+
|Well... ok... So we have a blank table, we have no data in our table whatsoever at the moment.
 
|-
 
|-
 
|0:36
 
|0:36
|આપણે જોઈ શકીએ છીએ કે અહીં કઈ જ નથી.
+
|we can see that there is nothing in here.
 
|-
 
|-
 
|0:40
 
|0:40
|અહીં ફક્ત આપણા ફીલ્ડનાં નામો છે.
+
|These are just our field names here.
 
|-
 
|-
 
|0:43
 
|0:43
|આ સાથે, અહીં શરૂ કરવા માટે, ચાલો આ પર માત્ર કમેન્ટ કરીએ.
+
|To begin with, in here, lets just comment this.
 
|-
 
|-
 
|0:47
 
|0:47
|તેથી '''"write some data"'''. ત્યારબાદ આપણે એક ક્વેરી સુયોજિત કરીશું જે ડેટા લખશે.
+
|So "write some data". Then we will set up a query that will write data.
 
|-
 
|-
 
|0:52
 
|0:52
|તેથી... '''"write"''' અને આપણે '''"mysql query"''' ફંક્શનને ઉપયોગમાં લઈશું.
+
|So... "write" and we will use "mysql query" function.
 
|-
 
|-
 
|0:59
 
|0:59
|અને આ બરાબર ૧ પેરામીટર લે છે જે આપણી '''sql''' ક્વેરી છે.
+
|And this takes exactly 1 parameter which is our sql query.
 
|-
 
|-
 
|1:01
 
|1:01
|આ કરવા માટે, ડેટા દાખલ કરવા માટે આપણે '''"INSERT"''' ટાઈપ કરીશું.
+
|To do this, we will type "INSERT" to insert data.
 
|-
 
|-
 
|1:06
 
|1:06
|આપણે '''"INSERT INTO"''' લખવા માટે જઈ રહ્યા છીએ.
+
|We are going to say "INSERT INTO".
 
|-
 
|-
 
|1:09
 
|1:09
|હવે આને મોટા અક્ષરોમાં લખવાનું કારણ એ છે કે આ '''sql''' કોડ છે.
+
|Now the reason I've typed this in capitals is because its sql code.
 
|-
 
|-
 
|1:14
 
|1:14
|જો હું કંઈપણ મોટા અક્ષરોમાં લખું છુ તો તેનો અર્થ એ છે કે તે '''sql''' કોડ છે.
+
|If I type anything in uppercase it means it is sql code.
 
|-
 
|-
 
|1:19
 
|1:19
|જો હું કંઈપણ નાના અક્ષરોમાં લખું છુ તો તેનો અર્થ એ છે કે તે અથવા તો કોષ્ટક નામ છે, ડેટાબેઝ નામ છે કે પછી ડેટા જે હું ડેટાબેઝમાં લખી રહ્યો છુ.
+
|If I type anything in lowercase it means its either a table name, database name or it is data that I'm writing to the database.
 
|-  
 
|-  
 
|1:30
 
|1:30
|તેથી '''"INSERT INTO people"''' કારણ કે આ અહીં આપણા કોષ્ટકનું નામ છે.
+
|So "INSERT INTO people" because that is our table name here.
 
|-
 
|-
 
|1:34
 
|1:34
|'''"INSERT INTO people"''' અને ત્યારબાદ '''"VALUES"''' અને પછી કૌંસમાં આપણે દરેક વેલ્યુ માટે થોડી જગ્યા બનાવીશું.
+
| "INSERT INTO people" and then "VALUES" and then in brackets we will create a little area  for each value.
 
|-
 
|-
 
|1:40
 
|1:40
|તો આપણને ૧,,,,૫ મળ્યું.
+
|So we got 1,2,3,4,5.
 
|-
 
|-
 
|1:46
 
|1:46
|અહીં ૫ ફીલ્ડો છે તેથી આપણને અહીં ડેટાબેઝનાં બરાબર ૫ ટુકડાઓ લખવાની જરૂર છે.
+
|There are 5 fields so we need exactly 5 pieces of database written here.
 
|-
 
|-
 
|1:50
 
|1:50
|આપણને '''id''', '''firstname''', '''lastname''' એજ રીતે નીચે '''gender''' સુધીની જરૂર છે.
+
|We need the id, firstname, lastname, all the way down to gender.
 
|-
 
|-
 
|1:55
 
|1:55
|આ એકલ અવતરણ અંદર અથવા એકલ અવતરણ વાપરીને બનાવામાં આવ્યું છે જે અલ્પ વિરામ દ્વારા અલગ થયેલ છે.
+
|These are created in or created using single quotes each separated by comas.
 
|-  
 
|-  
 
|2:03
 
|2:03
|આપણે દ્વિઅવતરણ ન વાપરવાનું કારણ એ છે કે આપણે આને અંતમાં મેળવ્યું છે અથવા કે શરૂઆતમાં અને અહીં સમાપ્ત થાય છે.
+
|The reason we don't use double quotes is because we've got these at the end or rather start and end over here.
 
|-
 
|-
 
|2:10
 
|2:10
|આપણે આપણું '''id''' અહીં દાખલ કરવાની જરૂર નથી.
+
|We don't need to insert our id here.
 
|-
 
|-
 
|2:13
 
|2:13
|આપણું આગળ આવનાર '''firstname''' છે - તેથી હું '''"Alex"''' લખીશ.
+
|Our next one is firstname - so I'll say "Alex".
 
|-
 
|-
 
|2:17
 
|2:17
|મારું '''lastname''' હું '''"Garrett"''' લખીશ.
+
|My lastname I'll say is "Garrett".
 
|-
 
|-
 
|2:20
 
|2:20
|મારી જન્મ તારીખ માટે હું એક ડેટ ફંક્શન બનાવીશ જે ચલ '''"date"''' સમાન છે.
+
|For my date of birth I'll create a date function which equals to a variable "date"
 
|-
 
|-
 
|2:26
 
|2:26
|હું આને એક ખાસ સ્ટ્રક્ચરમાં રાખીશ.
+
|I'll put this in the particular structure.
 
|-
 
|-
 
|2:28
 
|2:28
|આપણા ડેટાબેઝમાંથી અહીં જોઈ શકીએ છીએ કે જયારે આપણે એક વેલ્યુ દાખલ કરવા જઈએ છીએ, આપણે નીચે સ્ક્રોલ કરી શકીએ છીએ અને જોઈ શકીએ છીએ કે આપણા કેલેન્ડર ફંક્શનમાં તારીખો છે.
+
|We can see from our database over here that when we go to insert a value, we can scroll down and see that our calender function has dates on it.
 
|-
 
|-
 
|2:39
 
|2:39
|તેથી ૨૩ પર ક્લિક કરવાથી, આપણે આ ફીલ્ડ દ્વારા લેવાયેલ સ્ટ્રક્ચર જોઈ શકીએ છીએ.
+
|So on clicking 23rd, we can see the structure this field takes.
 
|-  
 
|-  
 
|2:45
 
|2:45
|આ વર્ષ છે, લાંબા ફોર્મેટમાં.
+
|Its the year in long format.
 
|-
 
|-
 
|2:47
 
|2:47
|આગળ મહિનો છે અને ત્યારબાદ દિવસ.
+
|Next is the month and then the day.
 
|-
 
|-
 
|2:48
 
|2:48
|તેથી '''2009 02 23''' જે ૨૦૦૯, ૨ જાંની ૨૩ છે.
+
|So 2009 02 23 which is 23rd of the 2nd, 2009.
 
|-
 
|-
 
|2:54
 
|2:54
|તો આપણે અહીં શું કરી શકીએ છીએ કે આપણને જરૂર છે એ સ્ટ્રક્ચર મેળવવા માટે આપણે આપણા date ફંક્શનને મોટા '''Y m''' અને પછી '''d''' માં સ્ટ્રક્ચર કરી શકીએ છીએ, વચ્ચે હાયફન (શબ્દતોડ કે શબ્દસાંઘણ ચિહ્ન) વાપરીને.
+
|So what we can do here is we can structure our date function in capital Y m and then d using hyphen in between to get the structure we need.
 
|-
 
|-
 
|3:05
 
|3:05
|તો આ પ્રમાણે તેનું સ્ટ્રક્ચર થશે.
+
|So this will be structured like that.
 
|-  
 
|-  
 
|3:09
 
|3:09
|આ આની બરાબર થશે અને આ વર્તમાન તારીખ થઇ જશે.
+
|This will equal to this and that will be the current date.
 
|-
 
|-
 
|3:13
 
|3:13
|ડેટ નો ઉપયોગ કરીને અને આ માનીને કે તે આપણા તારીખનાં સ્ટ્રક્ચરમાં છે, આપણે આને આપણા કોષ્ટકમાં અહીં દાખલ કરી શકીએ છીએ.
+
|Using the date and presuming that is in the structure of our date, we can insert it into our table here.
 
|-
 
|-
 
|3:24
 
|3:24
|અંતે છે '''gender''' અને જો કે હું એક પુરૂષ છું, હું પુરૂષ માટે '''"M"''' મૂકી રહ્યો છું.
+
|The last one is gender and since I'm a male, I'm putting in "M" for male.
 
|-
 
|-
 
|3:28
 
|3:28
|એ માનીને કે આ કામ કરશે, આપણે આ રન કરી શકીએ છીએ.
+
|Presuming that will work, we can run this.
 
|-
 
|-
 
|3:30
 
|3:30
|પણ એ પહેલા, આપણે અંતમાં એક '''mysql''' એરરનું અનુસરણ કરતા '''"or die"''' લખી શકીએ છીએ.
+
|But before that, we could say "or die" at the end followed by a mysql error.
 
|-
 
|-
 
|3:38
 
|3:38
|હમણાં માટે હું આ છોડી દઈશ પણ જો તમે ઈચ્છો તો આનો ઉમેરો કરવા માટે સંકોચાતા નહી.
+
|I will skip that for now but feel free to add them if you like.
 
|-
 
|-
 
|3:44
 
|3:44
|સારું તો આપણા પુષ્ઠને રીફ્રેશ કરીએ.
+
|Ok so refreshing our page.  
 
|-
 
|-
 
|3:48
 
|3:48
|તમે જે જોઈ રહ્યા છો તે પાછલા ટ્યુટોરીયલથી છે.
+
|What you see is from the last tutorial.  
 
|-  
 
|-  
 
|3:50
 
|3:50
|ઉમમમમ..... ચાલો આને કમેન્ટ કરીએ.
+
|ummmm..... Lets comment this out.
 
|-
 
|-
 
|3:56
 
|3:56
|ચાલો આને અવગણીએ.
+
|Lets ignore this.
 
|-
 
|-
 
|3:57
 
|3:57
|આ ટ્યુટોરીયલના આ ભાગને સંપૂર્ણપણે અવગણશે.
+
|This will completely ignore this part of tutorial.
 
|-
 
|-
 
|4:02
 
|4:02
|ઠીક છે - તો હું હાલમાં દર્શાવી રહ્યો છું તે કોડ પર પાછા ફરીએ અને ચાલો રીફ્રેશ કરીએ.
+
|Ok - so back to the code that I am currently showing and lets refresh.
 
|-
 
|-
 
|4:10
 
|4:10
|મેં આ બે વાર રીફ્રેશ કર્યું છે તેથી તે મુજબ ૨ રેકોર્ડો મુકાયા છે.
+
| I've refreshed it twice so accordingly 2 records have been put in.
 
|-
 
|-
 
|4:14
 
|4:14
|પણ પાછા બ્રાઉસ પર જઈને નીચે સ્ક્રોલ કરીને આપણે જોઈ શકીએ છીએ, ચાલો આમાંથી ૧ રદ્દ કરીએ, આપણે જોઈ શકીએ છીએ કે જે ડેટાને મેં હમણાં જ સ્પષ્ટ કરી છે તે ડેટાબેઝમાં મુકાઈ છે.
+
|But by going back to browse and scrolling down we can see, lets delete 1 of these, we can see the data I just specified has been put into the database.
 
|-
 
|-
 
|4:26
 
|4:26
|વાસ્તવમાં મેં શું કર્યું છે કે મેં વર્તમાન તારીખ તરીકે મારી જન્મ તારીખ મૂકી છે જે હું કરવા ઈચ્છતો ન હતો.
+
|In fact what I have done is I have put my date of birth as the current date which I didn't mean to do.
 
|-
 
|-
 
|4:33
 
|4:33
|હું મારી જન્મ તારીખને વર્તમાન તારીખ તરીકે ઈચ્છતો નથી કારણ કે મારો જન્મ આજે નથી થયો.
+
|I don't want my date of birth as the current date because I was not born today.
 
|-
 
|-
 
|4:39
 
|4:39
|મારું '''firstname''' ઠીક છે. મારું '''lastname''' ઠીક છે. મારું '''gender''' બરાબર છે.
+
|My firstname is ok. My lastname is ok. My gender is fine.
 
|-
 
|-
 
|4:43
 
|4:43
|આપણે જોઈ શકીએ છીએ કે આ સમયે મારી '''id''' ૬ છે અને આગળનાં સમયે આપણે એક રેકોર્ડને દાખલ કરીશું તો આ ૭ સુધી જશે અને પછી ફરીથી ૮ પર.
+
|We can see that my id is 6 at the moment and the next time we insert a record this would go up to 7 and then again to 8.
 
|-  
 
|-  
 
|4:53
 
|4:53
|તમને આ ખબર હોવી જોઈએ.
+
|You should know that by now.
 
|-
 
|-
 
|4:54
 
|4:54
|આગળ હું તમને બતાવીશ કે મારી જન્મ તારીખને કેવી રીતે બદલવી કારણ કે મેં એક ભૂલ કરી હતી.
+
|Next what I'll show you is how to change my date of birth because I have made a mistake.
 
|-
 
|-
 
|5:00
 
|5:00
|તેથી સૌપ્રથમ હું આ ૨ લાઈનોને કમેન્ટ કરીશ જેથી આપણને આ ફરીથી રન ન કરવું પડે.
+
|So first I will comment these 2 lines so we don't have to rerun this.
 
|-
 
|-
 
|5:04
 
|5:04
|અને હું એક નવું ચલ બનાવીશ. આપણે આને '''"update data"''' તરીકે કમેન્ટ કરીશું.
+
|And I'll create a new variable. We will just comment this as "update data".
 
|-
 
|-
 
|5:08
 
|5:08
|આ વર્તમાન ચલ '''"update"''' કહેવાશે અને તે '''"mysql query"''' ફંકશન બરાબર છે.
+
|Current variable called "update" and that's equal to "mysql query" function.
 
|-
 
|-
 
|5:14
 
|5:14
|અને પેરામીટર અંદર જે આપણે બોલાવી રહ્યા છીએ તે '''"mysql query"''' કોડ પોતે છે.
+
|And inside the parameter that we are calling is "mysql query" code itself.
 
|-
 
|-
 
|5:20
 
|5:20
|તો અહીં આપણે '''"UPDATE"''' ટાઈપ કરીશું અને આપણે કોષ્ટકનું નામ લખવા જઈ રહ્યા છીએ જે '''"people"''' છે.
+
|So here we will type "UPDATE" and we are going to say the table name which is "people".
 
|-
 
|-
 
|5:28
 
|5:28
|પછી આપણે '''"SET"''' લખીશું અને આપણે એક ખાસ ફીલ્ડ ને પસંદ કરવાની જરૂર છે જે સુયોજિત કરવું છે.
+
|Then we will say "SET" and we need to pick a particular field in which to set.
 
|-
 
|-
 
|5:34
 
|5:34
|આ '''"d o b"''' હોવું જોઈએ અને આ મારી વાસ્તવિક જન્મ તારીખ બરાબર છે જે છે ૧૯૮૯, વર્ષ જેમાં હું જન્મ્યો અને મહિનો નવેમ્બર છે અને દિવસ ૧૬ મો છે જેમાં મેં જન્મ લીધો.
+
|This happens to be the "d o b" and that's equal to my actual date of birth which is 1989, the year I was born in and the month is November and the day I was born is 16th.
 
|-
 
|-
 
|5:47
 
|5:47
|આ કમાંડ રન કરીને વાસ્તવમાં આપણે શું કરી રહ્યા છીએ કે આપણે આ કોષ્ટકમાં દરેકની જન્મ તારીખને આમાં સુધારી રહ્યા છીએ.
+
|By running this command what we are actually doing is we are updating everyone's date of birth in this table to this.
 
|-  
 
|-  
 
|5:54
 
|5:54
|આવું એટલા માટે કારણ કે આપણે એ સ્પષ્ટ નથી કર્યું કે આમાં સુધારાઓ ક્યાં જોઈએ છે.
+
|That's because we've not specified where we want to update this.
 
|-
 
|-
 
|5:57
 
|5:57
|પણ આપણે કરી શકીએ છીએ, કે આના પછી આપણે '''"WHERE id=6"''' લખી શકીએ છીએ કારણ કે મારી યુનિક '''id''' ૬ છે.
+
|But we can do is after this we can say "WHERE id=6" because my unique id is 6.
 
|-
 
|-
 
|6:08
 
|6:08
|ચાલો અહીં એક નજર ફેરવી લઈએ.
+
|Lets have a look here.
 
|-
 
|-
 
|6:10
 
|6:10
|નહી તો આ દરેકને સુધારીત કરી દેશે.
+
|Otherwise it will update everyone else's.
 
|-
 
|-
 
|6:12
 
|6:12
|યાદ રાખો મેં કહ્યું હતું કે '''id''' યુનિક છે. '''update my id''' કહેવું સારું રહેશે.
+
|Remember I said the id is unique. Its better to say update my id.  
 
|-
 
|-
 
|6:16
 
|6:16
|એના બદલે હું શું કરી શકું છું કે, લખું છું '''"WHERE firstname equals Alex"'''. જોકે આ દરેક એ રેકોર્ડોમાં સુધારણા કરશે જેનું '''ફર્સ્ટનેમ''' '''"Alex"''' છે.
+
|What I could do instead, is say, "WHERE firstname equals Alex". However this will update every record that has firstname "Alex".
 
|-
 
|-
 
|6:24
 
|6:24
|પણ આપણે આ પણ લખી શકીએ છીએ '''"AND lastname equals Garrett"'''.
+
|But we can also say "AND lastname equals Garrett".
 
|-
 
|-
 
|6:26
 
|6:26
|જોકે જો હજુ પણ ડેટાબેઝમાં આપણી પાસે ૨ લોકો છે જેનું ફર્સ્ટનેમ અને લાસ્ટનેમ સમાન છે, આપણે પહેલાની જ જેમ હજુ પણ એજ જોખમ રન કરીશું.
+
|However if we still have two people in the database with the same firstname and lastname, we are still running the same risk as before.
 
|-
 
|-
 
|6:43
 
|6:43
|તેથી શ્રેષ્ઠ રહેશે કે આપણા '''"unique"''' નો ઉપયોગ કરીએ અને તે મુખ્ય શબ્દ '''"unique id"''' છે જે મારી માટે ૬ છે.
+
|So its best to use our "unique" and thats the key word "unique id" which for me is 6.
 
|-
 
|-
 
|6:48
 
|6:48
|તો આ સમયે, તમે જોઈ શકો છો કે મારી જન્મ તારીખ ૨૦૦૯ પર સુયોજિત થઇ છે જે વર્તમાન તારીખ છે.
+
|So at the moment, you can see that my date of birth is set to 2009 which is the current date.
 
|-
 
|-
 
|6:53
 
|6:53
|પણ આ પુષ્ઠને રીફ્રેશ કરવાથી, કઈ પણ થયું નથી કારણ કે આપણે ફક્ત એક કમાંડ  રન કરી રહ્યા છીએ.
+
|But by refreshing this page, nothing's happened because we are just running a command.
 
|-
 
|-
 
|7:00
 
|7:00
|હવે જો આપણે રીફ્રેશ કરવા માટે બ્રાઉઝ પર ક્લિક કરીએ અને નીચે સ્ક્રોલ કરીએ, આપણે જોઈ શકીએ છીએ કે આ એમાં બદલાઈ ગયું છે જે આપણે સ્પષ્ટ કર્યું હતું અને બાકી તમામ બદલાયા વિનાનું રહ્યું છે.
+
|Now if we click on browse to refresh and we scroll down, we can see that it has changed to what we specified and everything else has been left intact.
 
|-
 
|-
 
|7:08
 
|7:08
|તેથી જો તમને તમારા ડેટાબેઝમાં ડેટા સુધારીત કરવાની જરૂર હોય અથવા કે એવુજ કઈ, તો તમે સ્પષ્ટ કરી શકો છો કે શું ડેટા તમે સુધારિત કરવા માંગો છો.
+
|So if you need to update data in your database or anything like that, you can specify what data you want to update.
 
|-
 
|-
 
|7:15
 
|7:15
|મેં '''"dob"''' ઉપયોગમાં લીધી હતી અને આ જન્મ તારીખનાં બરોબર હોય જે જરૂરી છે.
+
|I used "dob" and that equals to the date of birth that was necessary.
 
|-  
 
|-  
 
|7:18
 
|7:18
|હું મારું લાસ્ટનેમ સુધારીત કરી શકતો હતો.
+
|I could have updated my lastname.
 
|-
 
|-
 
|7:20
 
|7:20
|તમારે આ પણ સ્પષ્ટ કરવાની જરૂર છે કે તમે આને ક્યાં સુધારીત કરવા માંગો છો.
+
|You also need to specify where you want this to be updated.
 
|-
 
|-
 
|7:24
 
|7:24
|તેથી હું આ રેકોર્ડ કહીશ જે અહીં આ લાંબી લાઈન છે.
+
|So I said this record which is this long line here.
 
|-
 
|-
 
|7:28
 
|7:28
|આ રેકોર્ડ કહેવાય છે અને મેં સ્પષ્ટ કર્યું છે કે '''"WHERE"''' '''id''' ૬ ની બરાબર હતી અને તેણે મારા યુનિક રેકોર્ડને સુધારીત કર્યો છે.
+
|These are called records and I specified "WHERE" the id was equal to 6 and that has updated my unique record.
 
|-
 
|-
 
|7:35
 
|7:35
|તો આ બધું તમે શીખ્યા - કેવી રીતે વેલ્યુ દાખલ કરવી અને એ પણ કે કેવી રીતે અમુક વેલ્યુને સુધારીત કરવી જો તમે ખોટું કરી દીધું છે જેમ મેં કર્યું અથવા જો તમે કેટલાક ડેટાને સુધારીત કરવા માંગો છો જે કે ઘણી વખત થાય છે જયારે તમે તમારા ડેટાબેઝની સાથે કામ કરો છો.
+
|So that's what you have learnt - how to insert values and also how to update some values if you get it wrong like I did or if you just want to update some data which happens most of the time when your doing your databases.
 
|-
 
|-
 
|7:54
 
|7:54
|ઠીક છે - તો મારી સાથે આગામી ભાગમાં જોડાવો એ જાણવા માટે કે કેવી રીતે તમારા ડેટાબેઝમાંથી સુચના પ્રાપ્ત કરવી અને ડેટાને વપરાશકર્તા સમક્ષ પ્રદર્શિત કરવા.
+
|Ok - so join me in the next part to find out how to start reading from your database and display the data to the user.
 
|-
 
|-
 
|8:04
 
|8:04
|ફરી જલ્દીથી મળીશું. IIT-Bombay તરફથી આ ટ્યુટોરીયલ ભાષાંતર કરનાર હું, ભરત સોલંકી વિદાય લઉં છું.
+
|See you soon. This is Juanita Jayakar dubbing for the Spoken Tutorial Project.

Revision as of 11:44, 6 December 2012

Time Narration
0:00 Hi, welcome back. In this tutorial we will write some data into a database.
0:06 To do this we will use our "mysql query" function.
0:10 Now you can see here that we have our... records....
0:16 I am redoing this tutorial because the first time I did it, it did not work.
0:21 So first of all, I will just delete this data here.
0:29 Well... ok... So we have a blank table, we have no data in our table whatsoever at the moment.
0:36 we can see that there is nothing in here.
0:40 These are just our field names here.
0:43 To begin with, in here, lets just comment this.
0:47 So "write some data". Then we will set up a query that will write data.
0:52 So... "write" and we will use "mysql query" function.
0:59 And this takes exactly 1 parameter which is our sql query.
1:01 To do this, we will type "INSERT" to insert data.
1:06 We are going to say "INSERT INTO".
1:09 Now the reason I've typed this in capitals is because its sql code.
1:14 If I type anything in uppercase it means it is sql code.
1:19 If I type anything in lowercase it means its either a table name, database name or it is data that I'm writing to the database.
1:30 So "INSERT INTO people" because that is our table name here.
1:34 "INSERT INTO people" and then "VALUES" and then in brackets we will create a little area for each value.
1:40 So we got 1,2,3,4,5.
1:46 There are 5 fields so we need exactly 5 pieces of database written here.
1:50 We need the id, firstname, lastname, all the way down to gender.
1:55 These are created in or created using single quotes each separated by comas.
2:03 The reason we don't use double quotes is because we've got these at the end or rather start and end over here.
2:10 We don't need to insert our id here.
2:13 Our next one is firstname - so I'll say "Alex".
2:17 My lastname I'll say is "Garrett".
2:20 For my date of birth I'll create a date function which equals to a variable "date"
2:26 I'll put this in the particular structure.
2:28 We can see from our database over here that when we go to insert a value, we can scroll down and see that our calender function has dates on it.
2:39 So on clicking 23rd, we can see the structure this field takes.
2:45 Its the year in long format.
2:47 Next is the month and then the day.
2:48 So 2009 02 23 which is 23rd of the 2nd, 2009.
2:54 So what we can do here is we can structure our date function in capital Y m and then d using hyphen in between to get the structure we need.
3:05 So this will be structured like that.
3:09 This will equal to this and that will be the current date.
3:13 Using the date and presuming that is in the structure of our date, we can insert it into our table here.
3:24 The last one is gender and since I'm a male, I'm putting in "M" for male.
3:28 Presuming that will work, we can run this.
3:30 But before that, we could say "or die" at the end followed by a mysql error.
3:38 I will skip that for now but feel free to add them if you like.
3:44 Ok so refreshing our page.
3:48 What you see is from the last tutorial.
3:50 ummmm..... Lets comment this out.
3:56 Lets ignore this.
3:57 This will completely ignore this part of tutorial.
4:02 Ok - so back to the code that I am currently showing and lets refresh.
4:10 I've refreshed it twice so accordingly 2 records have been put in.
4:14 But by going back to browse and scrolling down we can see, lets delete 1 of these, we can see the data I just specified has been put into the database.
4:26 In fact what I have done is I have put my date of birth as the current date which I didn't mean to do.
4:33 I don't want my date of birth as the current date because I was not born today.
4:39 My firstname is ok. My lastname is ok. My gender is fine.
4:43 We can see that my id is 6 at the moment and the next time we insert a record this would go up to 7 and then again to 8.
4:53 You should know that by now.
4:54 Next what I'll show you is how to change my date of birth because I have made a mistake.
5:00 So first I will comment these 2 lines so we don't have to rerun this.
5:04 And I'll create a new variable. We will just comment this as "update data".
5:08 Current variable called "update" and that's equal to "mysql query" function.
5:14 And inside the parameter that we are calling is "mysql query" code itself.
5:20 So here we will type "UPDATE" and we are going to say the table name which is "people".
5:28 Then we will say "SET" and we need to pick a particular field in which to set.
5:34 This happens to be the "d o b" and that's equal to my actual date of birth which is 1989, the year I was born in and the month is November and the day I was born is 16th.
5:47 By running this command what we are actually doing is we are updating everyone's date of birth in this table to this.
5:54 That's because we've not specified where we want to update this.
5:57 But we can do is after this we can say "WHERE id=6" because my unique id is 6.
6:08 Lets have a look here.
6:10 Otherwise it will update everyone else's.
6:12 Remember I said the id is unique. Its better to say update my id.
6:16 What I could do instead, is say, "WHERE firstname equals Alex". However this will update every record that has firstname "Alex".
6:24 But we can also say "AND lastname equals Garrett".
6:26 However if we still have two people in the database with the same firstname and lastname, we are still running the same risk as before.
6:43 So its best to use our "unique" and thats the key word "unique id" which for me is 6.
6:48 So at the moment, you can see that my date of birth is set to 2009 which is the current date.
6:53 But by refreshing this page, nothing's happened because we are just running a command.
7:00 Now if we click on browse to refresh and we scroll down, we can see that it has changed to what we specified and everything else has been left intact.
7:08 So if you need to update data in your database or anything like that, you can specify what data you want to update.
7:15 I used "dob" and that equals to the date of birth that was necessary.
7:18 I could have updated my lastname.
7:20 You also need to specify where you want this to be updated.
7:24 So I said this record which is this long line here.
7:28 These are called records and I specified "WHERE" the id was equal to 6 and that has updated my unique record.
7:35 So that's what you have learnt - how to insert values and also how to update some values if you get it wrong like I did or if you just want to update some data which happens most of the time when your doing your databases.
7:54 Ok - so join me in the next part to find out how to start reading from your database and display the data to the user.
8:04 See you soon. This is Juanita Jayakar dubbing for the Spoken Tutorial Project.

Contributors and Content Editors

Krupali, PoojaMoolya, Pratik kamble, Sandhya.np14, Sneha