Search
 
SCRIPT & CODE EXAMPLE
 

PHP

db raw update laravel

DB::table('users')->where('user_id',1)->update(array(
                                 'username'=>$username,
));
Comment

laravel db raw query execute

//true
$cards = DB::select("SELECT * ");

// false
$cards = DB::raw("SELECT * ");
Comment

laravel select raw where

 User::query()
                ->where('users.ban', '!=', 1)
                ->where('users.rights', '=', 1)
                ->leftJoin('users as referal', 'users.id', '=', 'referal.ref_id')
                ->whereNotNull('referal.id')
                ->select([
                    'users.id',
                    'users.name',
                    'users.telegram_id',
                    DB::raw('count(referal.id) as total_referal'),
                    DB::raw("(SELECT COUNT(ac_r.id) FROM users as ac_r WHERE ac_r.ref_id=users.id AND ac_r.ref_bonus = 1) as active_referal"),
                    DB::raw("(SELECT COUNT(ac_r.id) FROM users as ac_r WHERE ac_r.ref_id=users.id AND ac_r.ref_bonus != 1) as no_active_referal"),
                    DB::raw("((SELECT COUNT(ac_r.id) FROM users as ac_r WHERE ac_r.ref_id=users.id AND ac_r.ref_bonus = 1) * ".User::REFERAL_BONUS.") as total_money_referal"),
                ])
                ->groupBy('users.id')
   ->orderByDesc('total_referal')->paginate(100);
Comment

PREVIOUS NEXT
Code Example
Php :: woocommerce profile photo upload 
Php :: log data into file php 
Php :: getMessage in php 
Php :: Str laravel 9 
Php :: database collection to array 
Php :: substract 2 dates php 
Php :: laravel update table column 
Php :: convert numeric array to string array php 
Php :: laravel 4.2 migration 
Php :: laravel redirect with message to section 
Php :: image store short method in laravel 
Php :: Undefined index: id 
Php :: download laravel 8 zip 
Php :: set names utf8 
Php :: how to go to another folder in php 
Php :: PHP not working centos 8 
Php :: laravel username validation 
Php :: laravel collection find duplicates 
Php :: access json object in php 
Php :: how see the list all artisan in laravel 
Php :: php remove and  
Php :: php session destroy 
Php :: laravel empty query result 
Php :: php program to find factorial of a number using function 
Php :: send multiple mail in laravel 
Php :: laravel validation regex 
Php :: redrectnh to https n laravel 
Php :: laravel make component 
Php :: laravel sortby relationship column 
Php :: HTML5 Date Valu In PHP 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =