 Everybody it's Brian and welcome to the ninth yeetoo tutorial. We're gonna go in here and In our previous tutorial we did a one-for-one relationship now We're gonna work with multiple rows or multiple models if you will so we're gonna go into our little test function here And we're gonna say Pets whoops, that's embarrassing All right, and whenever I do where I always kind of like instinctively do this Just so I know that I want to work with it in a special format All right, and then we can go name equal where you give it a variable called name damn you netpeens. Why have you betrayed me? There we go now this right here will return one item If we want to return all of them, we would have to say all Now if we want to limit the number of returns we would say well limit And then let's say to This is called I think it's called function chaining where you have an object and then you just chain one function after another So we're doing find where Limit all and that's kind of how that works. So we're gonna say if This set and I'll say It's like winter time here in Michigan and well, it's winter time everywhere But in Michigan, it's very dry and very it was very cool But now she's very dry my like my knuckles are all chapped so it kind of hurts to type Or say number of dogs found kind of embarrassing the pets. All right I've been playing XCOM lately. So now I'm like my brain is stuck in XCOM mode. It's like a strategy game And it's actually very challenging warming Wow Warning, maybe I need a typing game. All right, so No dogs found we're just doing a little bit of defensive programming here So if you go to lunch and somebody comes in and wipes out the whole database You're not scratching your head wondering why your code isn't working All right, so we're just saying you know number of dogs found and we're just gonna test this little theory that this does indeed limit it to two let's do this and number of dogs found to So that is very simply how you would do that Let's go back in here. Let's get rid of this limit because we want to work with all of them here And we're gonna say Hmm for each I love for each I remember we're in languages before for each existed And it was just such a pain every time you wanted to do a loop you had to do for I equal int as number of blah blah blah All right, so we're gonna get the individual items here and we're just gonna say yeah Info I'm gonna say the primary key of each one remember the primary key is the record identifier So we know which one we're actually looking at here Let's just print this bad boy out Uh-oh Undefined variable pet Hmm. I Have made a boo boo There we go. All right, let's go to our log and sure enough there is three dogs found But we had more than three in there We do have more than three. Oh, yes, I have misspelled a few My spelling skills are much to be desired here. So if we just go back Alright, there we go. Now we've got five dogs. Shum. So we've got Sparky 11 12 13 14 and 15 So what we want to do is we want to actually rename these things And I kind of want to show you in the log how this works rather than printing it out in the web page So you can see exactly why logging is important and how this is really working under the hood All right, so we're gonna take each one of these we're gonna say Sparky I'm not gonna wait for intelligence that takes forever sometimes So what we're really gonna do is we're just gonna validate that thing and then save it if it validates And you know, we should probably say else just in case something boo boo is out there big ominous error message here And we will go back out here and go back which it runs the script And when we look we can see how number of dogs found Sparky 11 update Sparky 12 update So we're doing an update on each an individual one So that is kind of how ye executes this under the hood now You can do like an update all or something like that, but I kind of wanted to show you this is a very I wouldn't even call it processor intensive communication intensive between the app and the database because you're doing all of these One after another and when we go out to our database here, you'll see they're now renamed So what happens if we just we hate Sparky and we want Sparky to go away I'm a cat person not a dog person personally, but I would never you know condone animal abuse at all But we just want Sparky to go bye-bye Well, we can kind of take the same format here and we can say Pets delete all and you notice how it IntelliSense finally popped up You've got delete all and then delete all condition and then condition params. Now, what are these? Well condition is just your sequel. So like you could say name equal and then Sparky Where that's really not the best way to do it. I prefer doing it like this where like or whatever or name equal and then the variable and You know the same thing that we really essentially have here and that would delete anything with the name of Sparky Or you could if you just want to live fast and dangerous here You could just delete all which is exactly what we're going to do for this tutorial and boom Delete from pets. So it just wiped it right out. So if we go to our database here Sparky go bye-bye All right. Well, that's all for this tutorial. I hope you found this educational and entertaining and as always check out my new YouTube channel I got tons of others videos on different programming languages either and Voidrums.com is my main website Go ahead and go to contact and then be sure to join the Voidrums Facebook group We got like almost 400 people in there with multiple languages. So if you have any questions or ideas, just bounce it off those guys And they can honestly I get an answer within about 10 minutes. So it's actually kind of cool. I'm pretty psyched up Talk to you later. Bye