Laravel 8 tutorial - Query Builder
HTML-код
- Опубликовано: 4 окт 2024
- In this laravel 8 and laravel 9 video tutorial, we learn what is query builder and how to make it a simple way. This video is made by anil Sidhu in the English language.
steps of video
Query Builder in Laravel
what is Query Builder in Laravel
Where Condition
Find, Count,
Insert,Update,Delete
Interview Question for query in laravel
Laravel tutorial for fresher
Laravel 9
Laravel 9 playlist tutorial
• Laravel 9 tutorial
Please support me by subscribe, like and comment :) thank you
Hi bro, Thanks for this tutorial. Here's the answer for your question. Hope you'll reply.
$id=13;
$data=(array)DB::table('students')->find($id); //it will find id
if($data){
echo "number already exists"; //if already id exists this will be printed
}else{
return DB::table('students')
->insert(['id'=>$id,
'name'=>'dffd']);
}
But id is a primary key. So there is no duplicate value of id in table then why are you checking the id is already exist or not
thanks bro for your good teaching
Thanks for this tutorial Anil. Which is better to use, models or the query builder, and when do we use which?
Query builder is litle bit faster
models are better and more sufficient plus u will have cleaner codes
SELECT `id`,`registration_number`,`fullname`,`gender`,(select count(*) FROM `registration_school_college_students` WHERE `gender`='male') as 'total_male' FROM `registration_school_college_students` WHERE 1.
How can i write the above query in laravel? Help needed
Sir, e-commerce website development के लिए कौन कौन से module होते हैं। Companies किस तरह से और कौन कौन से steps को follow करती हैं। Pro web development complete process kya होता है
what is the answer in the question?
Query builder or eloquent which is best approach to follow
It is upto u ...
How can write this type of query in eloquent.. please help me
thank you.
Excellent tutorial, especially when you combine it with 3 previous videos. You got yourself a subscriber!
$data=(array) DB::table('members')->findOrFail($id);
Contact kayse hoga aapse ek project banwana hai
webanilsidhu@gmail.com
thanku but can u add a number for the videos please from first to end its confusing
link ku nhi deya form py qurey builder apply krny ka
$data= DB::table('quotes')->find(16);
if($data) {
return 'already exists';
}
else {
DB::table('quotes')->insert(['heading'=>'inserted from query',
'description'=>'about inserted from query']);
}
$data = DB::table('members')->get();
return \view('memberQB', ['data' => $data]);
If you send the data this way to the view file and access it as an array in that view file, then it will not work. Like -
@foreach($data as $item)
{{ $item['id'] }}
@endforeach
Even if you cast it as an array it still not working.
You need to access it as an object. Like -
@foreach($data as $item)
{{ $item->id }}
@endforeach
P.S - If I am wrong correct me, please.
laravel.com/docs/8.x/queries#retrieving-results