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 :: laravel relationship hasmany 
Php :: remove public path from url laravel 
Php :: artisan call composer dump in controller 
Php :: count rows mysql limit php 
Php :: unexpected variable 
Php :: nl_langinfo — Query language and locale information 
Php :: Multiple trait declaration in PHP 
Php :: wordpress give query a unique identity 
Php :: Calling the JS file via WP PHP 
Php :: learndash logo link 
Php :: set additional params to form laravel 
Php :: laravel load relationship including empty values 
Php :: Laravel display the date the participation was created 
Php :: upload video file in mysqli using php 
Php :: Laravel image validation just reloads page and does nothing 
Php :: Comment supprimer les éléments liés à WordPress oEmbed 
Php :: "A non well formed numeric value encountered 
Php :: how we show full name of month in posts 
Php :: hardening PHP7 
Php :: trying to change iframe location from javascript 
Php :: laravel Undefined index: token on reset 
Php :: prestashop category as homepage 
Php :: pagenavi plugin 
Php :: laravel query with optional filter 
Php :: wordpress pass parameters variables arguments to enqueued script 
Php :: Regenerate session ID and remove all session data 
Php :: laravel app service provider why eloquent model error 
Php :: disableTimeRanges 
Php :: doctrine findby regex 
Php :: PHP 7 - Fatal error: Call to undefined method PDF::FPDF() 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =